The problem of initial parameters in Lsqcurvefit

I have a problem in Lsqcurvefit.
I am optimizing Boucwen Model with lsqcurvefit.
But when it runs with the initial parameters of below, it says
"Matrix dimensions must agree. Error in lsqcurvefit/objective (line 265)
F = F - YDATA; "
a = [1,1,1,1,1,1];
But if i use this initial parametes of below by looking for manually, it works well .
a = [12,5966,29,147,538,245];
Since I have 300 datas, I can't find each initial parameters.
So I read two ways of below such as exitflag, output and optimooptions.
I dont understand well which things are good for mine, So could you give me the recommendations for solving this problem?
Thank you so much.

 Accepted Answer

Matt J
Matt J on 25 Nov 2018
Edited: Matt J on 25 Nov 2018
So could you give me the recommendations for solving this problem?
Check the output of predicted(). Make sure it has the same dimensions as ydata2.

3 Comments

Thank you.
I understand that the dimesions chance depends on initial parameters, right?
And then how can I make same demension in this case?
force predicted is interpolated. But ydata is not interpolated.
So I need to interpolate ydata. or I have to get not random span by ODE function.
Is there another way for this?
force predicted is interpolated. But ydata is not interpolated.
Isn't it? What is this line doing in your code?
ydata2 = interp1(time, ydata,t,'spline');
When it is optimized
lsqcurvefit(predicted,a,t,ydata2);
here, predicted funtion gives output interpolated by random time span.
So, it needs to fit same vector between predicted output and ydata.
I made 't function' additionaly for getting 't' number for interpoltating ydata to ydata2.
But I think now, t function just is get 'initial parameter' just one time.
therefore, ydata2 has always same vector.
However, predicted output vector is changed depends on 'parameters optimizing in real time'.
I wonder how can i fix this error.
The more initial parameters are close at parameters that i want, it works well without problem coincidently.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 25 Nov 2018

Edited:

on 26 Nov 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!