
How to use lsqcurvefit on labelled contours for an image
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ogheneochuko
le 13 Oct 2015
Modifié(e) : Matt J
le 13 Oct 2015
Hello all, Though I have done some reading, I still do not understand how to apply the lsqcurvefit to the labelled contour I plotted from the image based on the mat file attached. The program I used is included below. Please can someone help me out.Thanks.
Z = load('Ir_6716.mat');
flds = fieldnames(Z);% Fieldnames of data.
field = flds{1};% First field in data structure.
A = Z.(field);
B = -272.+A;% converts from kelvin to celsius
contour(flipud(B));
[C,h] = contour(interp2(flipud(B),'spline'));
clabel(C,h);
0 commentaires
Réponse acceptée
John D'Errico
le 13 Oct 2015
Modifié(e) : John D'Errico
le 13 Oct 2015
Um, you can't. I.e., you cannot really use lsqcurvefit here, at least to any useful purpose on those contours. Why not?
- lsqcurvefit requires a model. You have not posed a model that has the fundamental shape of those contours. I seriously doubt whether you can come up with one either.
- lsqcurvefit requires a model of the essential form:
y = f(x,P)
here, P is a vector of the set of parameters to be estimated, and x is the independent variable. So in your case, you have no single valued function, y(x). You have a closed contour, so not a single valued function of an independent variable.
- For a given contour level from that plot, for example, at z = 25, there are MANY distinct, disjoint closed contours at that iso-level. You would need to build separate models for each of them.
At best, you MIGHT choose to extract the points for any given contour, then convert to polar coordinates. Now, build a model of the form
r = f(theta,P)
First though, you will still need to choose a model for that relationship.
Sorry, but whoever told you that lsqcurvefit would work here was probably thinking of a simpler case. (Or perhaps they simply have no concept of what lsqcurvefit does or how to use it.)
For example, suppose I did this:
[x,y] = meshgrid(0:.01:1);
z = exp(x.*y);
contour(z)

Now, I could extract any of those disjoint contours. Then I could come up with an intelligent model for that contour. In this case, I know it to be of the form
y = k./x
where k is an unknown constant. lsqcurvefit would have no problem solving this.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Problem-Based Optimization and Equations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!