I have the following code. As you can see it sorts some data, then performs a stepwise regression with the data. I need the output for each loop printed, preferably all on the same sheet (B is the only output I want). You can see where I have made an attempt under %Get Output. I am a total matlab newbie and horrible at it so as much detail as possible would be appreciated. Thank you in advance for any help!
%Sort the Data [rows, cols]=size(A03); for i = 1:rows
for j = 1:cols
y=zeros(8,1)
x=zeros(8,3)
for m=1:8
y(m)=NDVI((m-1)*rows+i,j)
x(m,1)=PET((m-1)*rows+i,j)
x(m,2)=P((m-1)*rows+i,j)
x(m,3)=Amp((m-1)*rows+i,j)
end
%Run the stepwise Regression
if sum(sum(isnan(x)),2)==0 && sum(isnan(y))==0
xx=x(:,1:3); yy=y(:,1);
[B,SE,PVAL,INMODEL,STATS,NEXTSTEP,HISTORY]= ...
stepwisefit(xx,yy,'penter',.05);
%Get Outputs
B = zeros(size(A03));
[B(1:1, 1:3, :)] = stepwisefit(xx,yy,'penter',.05);
end
end
end

댓글 수: 3

dpb
dpb 2015년 2월 26일
Do NOT delete questions if you intend to have them answered...I had just finished composing an answer and tried to post it to discover the link had disappeared. :(
Fortunate for you I had saved the text of what I wrote or I wouldn't have bothered to do it again.
BTW, edit your question to format the code; I'm not doing that again.
Robert
Robert 2015년 2월 26일
Thanks for your help! I didn't delete the question, not sure what you mean...
dpb
dpb 2015년 2월 26일
Hmmm....somebody did; the same question w/o the "URGENT" label disappeared between the time I first responded but was gone by time tried to Submit...if it wasn't you who did it, sorry.

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2015년 2월 26일

0 개 추천

...
[B,SE,PVAL,INMODEL,STATS,NEXTSTEP,HISTORY]= ...
stepwisefit(xx,yy,'penter',.05);
%Get Outputs
B = zeros(size(A03));
[B(1:1, 1:3, :)] = stepwisefit(xx,yy,'penter',.05);
...
Above you computed the coefficients and then immediately wiped them out and then do the work all over again...what's the point in that??? :)
If all you're wanting is to output the coefficient array, then
[B,SE,PVAL,INMODEL,STATS,NEXTSTEP,HISTORY]= ...
stepwisefit(xx,yy,'penter',.05);
dlmwrite('file.txt',B,'delimiter',' ','precision','%14.8f','-append')
Adjust format to suit and obviously use a better file name and it would be good to also add some sort of identifier as to case number or something to identify who's who in the zoo of models.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2015년 2월 26일

댓글:

dpb
2015년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by