MATLAB: Error in for loop

for loop

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

Best Answer

  • 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