필터 지우기
필터 지우기

Output looped values to the same array/matrix

조회 수: 1 (최근 30일)
Robert
Robert 2014년 12월 9일
답변: Guillaume 2014년 12월 9일
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!

채택된 답변

Guillaume
Guillaume 2014년 12월 9일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by