MATLAB Answers

0

LSQCURVEFIT Global Fit Unequal Data Question

Asked by Kelly McGuire on 3 Aug 2017
Latest activity Commented on by Torsten
on 7 Aug 2017
Ok, so I am trying to do a global fit of multiple traces to obtain 4 parameters. I have 15 traces that I am trying to fit at the same time using LSQCURVEFIT. Everything works fine if the data in my matrix has an equal number of columns in each of the rows. But, here is the problem. For 6 of the 15 traces, I collected more data. Now, yes I could just delete some of that data so that the number of columns is equal in each row, but my professor wanted more data for the global fit for those 6 traces intentionally. I won't go into detail as to why more data was required for those 6 traces. My question though is how can I do this fit using LSQCURVEFIT if the number of columns for these 6 traces is greater in those 6 rows than the other 9 rows? I'll get errors like index exceeds matrix dimensions (even if the other columns from the other 9 rows is filled with NaN). How can I do this fit with unequal columns in some of my data rows? I read that using cell arrays might work, but I couldn't figure out how with this kind of fit.

  6 Comments

So I tried using cell arrays, but I keep getting the error 'lsqCURVEFIT requires the following inputs to be of data type double'. Is there a way to make the cell array type double?
John D'Errico, could you elaborate on your first sentence, "You don't need to have the same number of points on each curve to make lsqcurvefit work."?
Use "lsqnonlin" instead of "lsqcurvefit".
Then you don't need to use "xdata" and "ydata" as direct input for the solver and you can define them as cell arrays.
Best wishes
Torsten.

Sign in to comment.

0 Answers