Quantcast
Channel: MATLAB Central Newsreader - tag:"optimization"
Viewing all articles
Browse latest Browse all 130

Re: 3D Curve Fit

$
0
0
How to do 3d curve fit using this function?
all of the examples are 2d.

"Craig Cowled" wrote in message <ko61sl$87m$1@newscl01ah.mathworks.com>...
> Fabian,
>
> I just noticed your question. No doubt you have made some progress of your own in the last month or so. I am also very interested in curve fitting a 3D locus, however, my function is somewhat different to yours and my axes are Frequency, Real and Imaginary.
>
> I have found that the LSQNONLIN optimisation function is very helpful in addressing this problem. Essentially, the LSQNONLIN function minimises the residual error between your data and the curve you are trying to fit, using a least squares method. It is very fast, however, it is prone to finding local minima rather than global minima.
>
> I have posted my code at:
>
> http://www.mathworks.com/matlabcentral/answers/60638-curve-fitting-a-complex-function-using-cftool
>
> Feel free to adapt this code to your own purpose.
>
> MattJ helped out by showing me how to evaluate the residuals of the Real and Imaginary parts separately (he also suggested using LSQCURVEFIT). It's not a perfect method because you need to provide bounds to your coefficients and input a reasonably good guess at your initial values in order to get reasonable results.
>
> If you are finding that your results aren't that good, it could be because you are falling into a local minima. In that case, it might be worthwhile using a Genetic Algorithm to obtain initial values for LSQNONLIN. The GA is very robust, however, it is computationally expensive. You can find out more about GA by looking up the Matlab help file on the function 'GA'. There is also a GUI for the GA that is useful for gaining an understanding of how it works, but I would recommend writing code once you've figured out how to use the function.
>
> I have also noticed that it is very important to get your objective function (the one that outputs the value you are trying to minimise) just the way you want it. In my case, I have recognised that I still need to change my objective function a bit in order to get a better curvefit.
>
> Good luck,
>
> Craig.
>
> "Fabian" wrote in message <kl8hv9$bjf$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > for my thesis I want to fit the Johson-Cook material model, where the plastic stress depends on the plastic strain, the strain rate and the three Johnson-Cook material parameters which have to be fitted.
> > I have the plastic strain, the strain rate and the stress as input and want to fit the parameters to meet the yield curve. This means a 3D curve fit (x-axis is strain, y-axis is strain rate and z-axis is the yield stress).
> >
> > I tried this with the following code:
> >
> > % FitOpt = fitoptions('Method','LinearLeastSquares',...
> > % 'Lower',[0,0],...
> > % 'Upper',[max(L1),Inf]);
> > % FitType = fittype('JCA + (JCB*x)^JCN*(1 + JCC*log(y)','problem','n','options',FitOpt);
> > % JCYC = fit(JC1,JC2,FitType);
> >
> > ---
> > JC1 is the strain (x), JC2 the strain rate (y).
> > Unfortunately it doesn't work. Does anybody see the mistake or has some advice which function to choose to solve this problem. The problem is that MATLAB wants to fit a surface when two vectors are input as data and one as target, but i need a curve.
> >
> > Many thanks in advance!
> >
> > Regards,
> > Fabian

Viewing all articles
Browse latest Browse all 130

Trending Articles