Rank: 4 based on 3781 downloads (last 30 days) and 52 files submitted
photo

John D'Errico

E-mail
Company/University
Retired

Personal Profile:

Mainly retired from Eastman Kodak. (Of course, Kodak itself is now semi-retired. I don't think I had any influence in that.) I still write MATLAB code as I find something interesting, but I DON'T answer your questions, and I do NOT do homework. Your homework is YOUR problem, not mine. Do NOT e-mail me with your homework problems or student projects. When I'm not doing something with MATLAB, you might find me playing bridge.

Professional Interests:
Bridge, MATLAB, numerical analysis, mathematical modeling

 

Watch this Author's files

 

Files Posted by John View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
23 May 2014 Screenshot A suite of minimal bounding objects Suite of tools to compute minimal bounding circles, rectangles, triangles, spheres, incircles, etc. Author: John D'Errico miminum, bound, bounding, circle, rectangle, triangle 90 16
  • 4.66667
4.7 | 6 ratings
29 Apr 2014 polyfitn Polynomial modeling in 1 or n dimensions Author: John D'Errico polyfit, modeling, regression, linear regression, approximation, function 281 42
  • 4.95652
5.0 | 23 ratings
29 Apr 2014 Screenshot SLM - Shape Language Modeling Least squares spline modeling using shape primitives Author: John D'Errico spline, splines, cubic, hermite, breaks, knots 178 100
  • 5.0
5.0 | 52 ratings
29 Jan 2014 Moving window standard deviation A (fast) windowed std on a time series Author: John D'Errico standard deviation, std, window, filter, movingavg 84 16
  • 4.72727
4.7 | 11 ratings
30 Oct 2013 HPF - a big decimal class High precision floating point arithmetic, a new class written in MATLAB Author: John D'Errico hpf, multiple precision, big decimal, floating point, arithmetic, mathematics 44 17
  • 5.0
5.0 | 7 ratings
Comments and Ratings by John View all
Updated File Comments Rating
28 Jul 2014 bisection bisection root finding code Author: osman onur g├╝rler

Poor, even disregarding that the error messages are unreadable to most people.

It starts with clc, clear all. Yes, this is homework, but for anyone to use it in any serious way, it is not a function, but a script. So clearing the person's workspace makes this useless, and in fact, just a bit malicious for actual use. (You need to recognize that what is acceptable for homework is in fact terrible for anyone who will do real work.)

Of course, why anyone would use bisection instead of fzero is beyond me, so I seriously doubt that anyone will use it for more than homework.

Looking at the code, it is also moderately poor. WHY WOULD YOU USE SYMS? Please tell me why anyone needs to create a symbolic function, then use subs to evaluate the function. LEARN TO USE FUNCTIONS! So learn about anonymous functions, function handles, feval, even inline functions are an option.

If all this is is a teaching tool, because it really is a homework assignment, it does not have any internal comments. Of course, most people could not read them anyway.

The cariable names are poorly chosen, c,k,m, etc. USE self documenting variable names. You don't get charged per character of code, but you WILL find that readable code makes it easier to debug. ANd most people will find bugs in their code at some time or another. So learn to write readable code!

The interface is poor, with inputs to bring in everything. Ugh, useless, even as homework. No error checks.

Oh, the code again ... There is no check for number of iterations, so this code could potentially go into an infinite loop.

Overall, poor, even as homework.

26 Jul 2014 Surface Fitting using gridfit Model 2-d surfaces from scattered data Author: John D'Errico

No, gridfit does not explicitly allow you to apply derivative constraints. That does not say it is impossible, only that I did not offer it as an option.

The main reason why not, is it would require a set of linear inequality constraints on the unknowns. For a not uncommon grid of size 100x100, there are 100*100=10000 unknowns to solve for. This is not a problem, since the linear system is a sparse one. However, to solve a sparse linear inequality constrained system, one would need to use LSQLIN, or a solver like it. And the last time I checked, LSQLIN was not set up yet to handle sparse large scale inequality constrained problems. (That may have changed with the most recent release, but I have not checked.) If I made all of the matrices full ones, the solve time would probably be incredibly slow and memory intensive.

So I'm sorry, but gridfit will not handle the problem as is.

If you were willing to build a fairly coarse grid, AND add the constraint system, it would probably be doable in a reasonable time. I don't know how small the grid would need to be to make the solve time reasonable. And your definition of reasonable would surely differ from mine, depending on how badly you needed the answer.

26 Jul 2014 Inhull Efficient test for points inside a convex hull in n dimensions Author: John D'Errico

Andy - there are a few ways to solve your problem.

Once an object is no longer convex, the answer is not as easy. Inhull uses a simple and efficient trick, converting all facets of a convex surface into linear inequalities, so the test becomes not much more than a simple (large & sparse) matrix multiply. However, the linear inequality approach fails when the object is no longer convex, and there is no such thing as only slightly non-convex. So, some simple alternatives are:

- Form a tessellation of the non-convex domain, converting it entirely into a list of simplexes that fill the region. A point is inside the surface if it is inside ANY of the component simplexes. This is doable, although a bit slower than inhull would be. The biggest issue is how one converts a surface into a full tessellation.

- Another scheme is to use a ray. A point is inside the domain if any random ray extending from that point to infinity passes through an odd number of facets of the surface. Clearly you need to be careful if the ray happens to be parallel (and coincident with) a facet or edge, or it passes through a vertex. As well, one needs to write careful code to determine what happened if the point fell exactly on a facet, edge, or vertex.

02 Jul 2014 SLM - Shape Language Modeling Least squares spline modeling using shape primitives Author: John D'Errico

Mustafa - I'm glad you like it.

The initial knot placement is as you supply it, or if you supplied nothing, then the default is used. By default, the knots chosen are equally spaced from min(x) to max(x), with 6 knots in total, so there would be 4 interior knots to vary. The optimizer then varies only those interior knots.

There is no overt randomness in the optimization or the initial values though. For example:

x = rand(100);
y = exp(x);

clear functions
tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 1.369497 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.176209 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.127645 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.123504 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.121428 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.123522 seconds.

tic,slm = slmengine(x,y,'knots',6,'interiorknots','free');toc
Elapsed time is 0.126947 seconds.

The difference in time for the subsequent calls is small, but non-zero. That variability is purely due to your CPU as it is constantly running various other things in the background.

ALWAYS do such time tests multiple times, and ignore the first couple of calls from your sample, as the first time a function is called, MATLAB takes extra time to cache the JIT parsed code. Above, see that I did a clear functions first to clear the function cache. The first call was quite slow, then after the second call, the time needed was far less, and quite consistent.

02 Jul 2014 SLM - Shape Language Modeling Least squares spline modeling using shape primitives Author: John D'Errico

I'm confused. If you found this page, you should be able to click on the "Download Submission" button. Once you have done that, unzip the file, and add the resulting directory to your search path using either addpath & savepath or pathtools.

Comments and Ratings on John's Files View all
Updated File Comment by Comments Rating
30 Jul 2014 Surface Fitting using gridfit Model 2-d surfaces from scattered data Author: John D'Errico Tafuni, Angelo

26 Jul 2014 Surface Fitting using gridfit Model 2-d surfaces from scattered data Author: John D'Errico D'Errico, John

No, gridfit does not explicitly allow you to apply derivative constraints. That does not say it is impossible, only that I did not offer it as an option.

The main reason why not, is it would require a set of linear inequality constraints on the unknowns. For a not uncommon grid of size 100x100, there are 100*100=10000 unknowns to solve for. This is not a problem, since the linear system is a sparse one. However, to solve a sparse linear inequality constrained system, one would need to use LSQLIN, or a solver like it. And the last time I checked, LSQLIN was not set up yet to handle sparse large scale inequality constrained problems. (That may have changed with the most recent release, but I have not checked.) If I made all of the matrices full ones, the solve time would probably be incredibly slow and memory intensive.

So I'm sorry, but gridfit will not handle the problem as is.

If you were willing to build a fairly coarse grid, AND add the constraint system, it would probably be doable in a reasonable time. I don't know how small the grid would need to be to make the solve time reasonable. And your definition of reasonable would surely differ from mine, depending on how badly you needed the answer.

26 Jul 2014 Surface Fitting using gridfit Model 2-d surfaces from scattered data Author: John D'Errico Javier

Hey John, would gridfit allow me to constraint the slope of the fitted surface for a given range of data?

I'm needing to model a surface in the form of z(x,y) from scattered data points while keeping the first derivative of z negative in both directions.

26 Jul 2014 Inhull Efficient test for points inside a convex hull in n dimensions Author: John D'Errico D'Errico, John

Andy - there are a few ways to solve your problem.

Once an object is no longer convex, the answer is not as easy. Inhull uses a simple and efficient trick, converting all facets of a convex surface into linear inequalities, so the test becomes not much more than a simple (large & sparse) matrix multiply. However, the linear inequality approach fails when the object is no longer convex, and there is no such thing as only slightly non-convex. So, some simple alternatives are:

- Form a tessellation of the non-convex domain, converting it entirely into a list of simplexes that fill the region. A point is inside the surface if it is inside ANY of the component simplexes. This is doable, although a bit slower than inhull would be. The biggest issue is how one converts a surface into a full tessellation.

- Another scheme is to use a ray. A point is inside the domain if any random ray extending from that point to infinity passes through an odd number of facets of the surface. Clearly you need to be careful if the ray happens to be parallel (and coincident with) a facet or edge, or it passes through a vertex. As well, one needs to write careful code to determine what happened if the point fell exactly on a facet, edge, or vertex.

25 Jul 2014 Inhull Efficient test for points inside a convex hull in n dimensions Author: John D'Errico Horn, Andy

Hello everybody!

I love inhull, it really helps a lot! However, I also have some objects that are not necessarily convex and would need to have a generalized version of this, which could e.g. read the outputs of a isosurface function (triangles and points).. Is anyone aware of a similar function to inhull which does exactly this? (testing if points reside within a surface described by points and triangles)?

Thanks a lot for your help!

Yours, Andy

Contact us