Why does the for loop show the graph of the last plot?
Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning.Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning. Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning. for loop, plot MATLAB Answers — New Questions