error in for loop

조회 수: 1 (최근 30일)
FIR
FIR 2011년 11월 8일
i have the following code
clc
out=[3 4 5 6 7 8]'
out1=[1 2 3 4 5 6]'
for i=1:size(out)
for j =1:size(out1)
xlabel([ 'resp',num2str(out(i))])
ylabel([ 'resp',num2str(out1(j))])
end
end
for this i get only one graph with X axis label as 3 and y axis label as 1
i need six graphs with x ad y label as in out and out1 .please help

채택된 답변

Wayne King
Wayne King 2011년 11월 8일
you're changing the value each time through the for loops.
How about:
out=[3 4 5 6 7 8];
out1=[1 2 3 4 5 6];
for nn = 1:6
subplot(3,2,nn)
xlabel(['resp ', num2str(out(nn))]);
ylabel(['resp ', num2str(out1(nn))]);
end
  댓글 수: 4
Andrei Bobrov
Andrei Bobrov 2011년 11월 8일
out=[3 4 5 6 7 8];
out1=[1 2 3 4 5 6];
for nn = 1:6
figure
xlabel(['resp ', num2str(out(nn))]);
ylabel(['resp ', num2str(out1(nn))]);
end
FIR
FIR 2011년 11월 8일
thanks andrei

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

추가 답변 (1개)

Jan
Jan 2011년 11월 8일
At first replace "1:size(out)" by "1:numel(out)". SIZE replies a vector.
Do you want the different diagrams inside on figure or on different figures? Currently you set the labels of a single diagram 36 times, therefore I'm not sure how you want to distribute this to 6 diagrams.
  댓글 수: 1
FIR
FIR 2011년 11월 8일
Jan i need 6 figures
ist figure X ,Y axis 3,1
2nd figure X ,Y axis 4,2
;
;
;
6th figure X,Y axix 8,6

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by