For loop execution for saving data in a matrix or file
Show older comments
Hi Everyone I have wrote a MATLAB code which fits the data for one curve and give me the value of x intercept. (linear fitting for the linear portion of the curve)
I have many curves similar to this one for which I need to use the same fit code which I wrote for one curve. So I think of writing a for loop to the whole code which will change the values of the x and y. I want all this data fit information for all the curve to be saved in one matrix (like the value of i, number of points it fitted, slope). For an instance for the below case the matrix values would be i = 1, number of points fitted = 4, slope = 0.5504. For changing the values I have this code. I need your input on this code, which I have below. I have the for loop written after this image. Please have a look and give your valuable suggestions/comments.
Thanks

for i =1:1:40
y = ((data2LoadR{3}(i,2:end))) %for all the 40 curves
x = (data2LoadR{1}) %x axis is same for all curves
%%......All the lines of code which I have for curve fit and give same
%%values I got in the screenshot case
Xintercept[1,i] = -b/m %save Xintercept in different location each time the loops run
n[2,i] = numel(A) %Save the number of points fitted
i[3,i] = i %Save the number of values of data
end
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!