Borrar filtros
Borrar filtros

Output looped values to the same array/matrix

1 visualización (últimos 30 días)
Robert
Robert el 9 de Dic. de 2014
Respondida: Guillaume el 9 de Dic. de 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!

Respuesta aceptada

Guillaume
Guillaume el 9 de Dic. de 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

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by