Asked by Kelly McGuire
on 3 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.

Opportunities for recent engineering grads.

Apply Today
## 6 Comments

## John D'Errico (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_474415

## Kelly McGuire (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_474432

## Torsten (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_474489

## Kelly McGuire (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_474595

## Kelly McGuire (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_474674

## Torsten (view profile)

Direct link to this comment:https://nl.mathworks.com/matlabcentral/answers/351468-lsqcurvefit-global-fit-unequal-data-question#comment_475009

Sign in to comment.