For Loops With Matrices
1 view (last 30 days)
Show older comments
Kelly McGuire
on 11 Apr 2017
Commented: Star Strider
on 11 Apr 2017
So, I am trying to perform a global fit on 15 data traces obtained from electrophysiology. The first three traces had a concentration of 10 micromolar, the second three traces had a concentration of 100 micromolar, the third three traces had 500 micromolar, the fourth had 1 millimolar, and the fifth had 10 millimolar. The traces are nanoamps vs milliseconds. Ok, so I want to globally fit these 15 traces using a nonlinear custom nonlinear function with lsqcurvefit. Fitting the first three traces was simple since they all had the same concentration. How would I fit all of these traces using my nonlinear function and lsqcurvefit in a loop where the concentration changes? I thought maybe putting all of the xdata (milliseconds) in one matrix, and the ydata (nanoamps) in another matrix and using those as the xdata and ydata that are called into lsqcurvefit, and that worked if the concentration is a fixed number. Now, how would I do this if my matrix was 15 dimensions, and every three columns I needed the nonlinear function to start using a different concentration? I hope this was mostly clear.
0 Comments
Accepted Answer
Star Strider
on 11 Apr 2017
Mostly, but not entirely.
The lsqcurvefit function is the correct choice.
It would be necessary to know the equations you want to fit, and if the concentration of the unknown substance could be parameterised within them.
How are the data related to the concentrations?
4 Comments
Star Strider
on 11 Apr 2017
I assume the varying concentration of ‘Co’ are accounted for by ‘k1’.
I would define the start time as the time the drug is added to the bath.
It seems that if you have all the other constants (such as ‘Co’, whenever in your experiment you measure it), this is a relatively straightforward two-parameter estimation problem. If so, design your objective function to accept ‘Co’ as an input argument. You may need to use a loop in your objective function to provide the appropriate values of ‘Co’ to fit each column (or row) in your objective function matrix. This is going to be slow, but should be successful. Turn off the sleep option for your computer while you run this.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!