Store fit output and call them later

1查看(最近30天)
Hussein Kokash
Hussein Kokash 2021年6月20日
Commented: Hussein Kokash2021年6月20日
Dears, hope all are doing great!
I have the following script I use to read files and then fit them using curve fitting, my goal is to store the output of the fit for each file so that I can plot them all using the same x-axis, so the idea is to replace y values with the new fit output for each file , how is that possible?
谢谢你,一个ppreciate it.
[file_list, path_n] = uigetfile('.txt', 'Multiselect', 'on');
filesSorted = natsortfiles(file_list);
if iscell(filesSorted) == 0;
filesSorted = (filesSorted);
end
for i = 1:length(filesSorted);
filename = filesSorted{i};
data = load([path_n filename]);
x = data (:,1);
y = data (:,2);
t =数据(1,3);
Time(i) = T;
% Curve fitting
f = fit(x,y,'fourier1')
%figure(i)
绘图(F,X,Y)
坚持,稍等
formula(f)
coefficients = coeffvalues(f)
end

Accepted Answer

Walter Roberson
Walter Roberson 2021年6月20日
f = fit(x,y,'fourier1')
一旦你有的话,你可以记录 f in a cell array.
Or... you can invoke
saved_x{i} = x;
saved_y{i} = y;
predicted_y{i} = f(x);
Here, predicted_y{i} will become a numeric vector of what the model values predict for the given x values; you would not need the fit object after that.
3 Comments
Hussein Kokash
Hussein Kokash 2021年6月20日
Superb!
Thank you!

Sign in to comment.

More Answers (0)

下载188bet金宝搏


发布

R2021a

Community Treasure Hunt

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

开始狩猎!