Filter löschen
Filter löschen

Output looped values to the same array/matrix

1 Ansicht (letzte 30 Tage)
Robert
Robert am 9 Dez. 2014
Beantwortet: Guillaume am 9 Dez. 2014
Basically, I have the code below. I want to generate 2 output files, one for B and one for PVAL, each of which should contain the outputs for each loop so I am left with 1 sheet containing all of the B values for each loop, and another sheet containing all of the PVAL values for each loop.
What do I need to add to the code to achieve this?
for i = 1:size(data,1)/8
xx=data(8*i-7:8*i,2:3); yy=data(8*i-7:8*i,1);
[B,SE,PVAL,INMODEL,STATS,NEXTSTEP,HISTORY]=stepwisefit(xx,yy,'penter',.05);
end
Thanks in advance for any help!

Akzeptierte Antwort

Guillaume
Guillaume am 9 Dez. 2014
You just need to predeclare your B and PVAL with the appropriate size and use your i index to put the result of stepwisefit in the relevant column:
numsteps = size(data, 1)/8;
B = zeros(2, numsteps);
PVAL = zeros(2, numsteps);
for i = 1:numsteps
xx=data(8*i-7:8*i,2:3); yy=data(8*i-7:8*i,1);
[B(:, i), ~, PVAL(:, i)] = stepwisefit(xx, yy, 'penter', .05)
end

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by