LSQCURVEFIT Global Fit Unequal Data Question

3 views (last 30 days)
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
Kelly McGuire
Kelly McGuire on 4 Aug 2017
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."?
Torsten
Torsten on 7 Aug 2017
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.

Answers (0)

Community Treasure Hunt

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

Start Hunting!