I = 1:2:columns ; N = length(I); iwant = cell(N,1) ; for i = 1:N col = I(I) ; x = data(:, col); y = data(:, col + 1); hold on; [xData, yData] = prepareCurveData(x, y); % Set up fittype and options. ft = 'linearinterp'; % Fit model to data. [fitresult, gof] = fit( xData, yData, ft ); InterAmp = fitresult(0:0.9765625:999); iwant{i}= InterAmp; end
how to save for loop data
1 view (last 30 days)
Show older comments
I have a script that is calling from an excel file and interpolating the data in a for loop. The result is stored in the variable 'interamp' and i just need to know how to save the data with each iteration of the loop, before it is overwritten.
filename = 'sample file.xlsx';
data = xlsread(filename);
[rows, columns] = size(data);
dAmp = []; % holds amp for each trialFFTamp
dPhz = []; % holds phz for each trial
ctr = 1;
for col = 1 : 2 : columns
x = data(:, col); y = data(:, col + 1); hold on;
[xData, yData] = prepareCurveData(x, y);
% Set up fittype and options.
ft = 'linearinterp';
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
InterAmp = fitresult(0:0.9765625:999);
end
0 Comments
Answers (1)
KSSV
on 19 Apr 2018
0 Comments
See Also
Categories
Find more on Interpolation 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!