MATLAB: Fminsearch to determine parameters of a function against a dataset

fminsearch

I want to be able to determine parameters of a given time dependent function to fit a time dependent data set. I am able to minimize the absolute value of the difference between these two data sets (indexing the function at specific times) and acquire parameters for each time point. Is there any way with fminsearch to determine parameters based on the entirety of both data sets? If not what is the best function to use in this circumstance? Thank you for the help.

Best Answer

Yes, use
norm(DataSet1-DataSet2)
to get a measure of the discrepancy across all the time samples instead of
abs(DataSet1(i) - DataSet2(i))
to get the discrepancy at only the i-th time sample. Even better, though, would be to use LSQCURVEFIT if you have it.