how to save for loop data
Afficher commentaires plus anciens
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
Réponses (1)
KSSV
le 19 Avr 2018
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;
endCatégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!