How do I define more than one matrix as i= on for loop?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I have these 3 loops:
for i = jumph
SJvsSJWA = ttest2(i(ref(:,3)),i(ref(:,1)));% jump height
CJvsCJWA = ttest2(i(ref(:,4)),i(ref(:,2)));
SJWAvsCJWA = ttest2(i(ref(:,1)),i(ref(:,2)));
SJvsCJ = ttest2(i(ref(:,3)),i(ref(:,4)));
end
for i = avp
SJvsSJWA = ttest2(i(ref(:,3)),i(ref(:,1)));% average power
CJvsCJWA = ttest2(i(ref(:,4)),i(ref(:,2)));
SJWAvsCJWA = ttest2(i(ref(:,1)),i(ref(:,2)));
SJvsCJ = ttest2(i(ref(:,3)),i(ref(:,4)));
end
for i = peakp
SJvsSJWA = ttest2(i(ref(:,3)),i(ref(:,1)));% peak power
CJvsCJWA = ttest2(i(ref(:,4)),i(ref(:,2)));
SJWAvsCJWA = ttest2(i(ref(:,1)),i(ref(:,2)));
SJvsCJ = ttest2(i(ref(:,3)),i(ref(:,4)));
end
What I want to do is combine the 3 for loops so that for example:
i = jumph:avp:peakp
but I am aware this wouldn't work, so need a way to do this.
The three variables jumph, avp and peakp are all 54 x 1 matrices.
댓글 수: 3
Star Strider
2014년 5월 19일
Before we go any further, it’s worth noting that in the code you’ve posted, you’re doing exactly the same operation in all three loops and saving only the last result in the last loop. You are also not saving the p-value because you’re not asking ttest2 to return it. The p-value is the only result you really need.
Franchesca
2014년 5월 19일
Star Strider
2014년 5월 19일
Is ‘i’ a loop counter (vector) or is it something else? (This may have a context I’m not familiar with.) I don’t know how your data are organised.
답변 (1개)
Matt J
2014년 5월 19일
One way,
for i=1:54
m=jumph(i);
n=avp(i);
p=peakp(i);
%do stuff with m,n,p
end
댓글 수: 2
Franchesca
2014년 5월 19일
Matt J
2014년 5월 19일
If so, then what benefit are you seeking in combining the loops? The existing code will do that already.
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!