how to plot many lines on the same graph

조회 수: 2 (최근 30일)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2018년 7월 24일
댓글: MAHMOUD ALZIOUD 2018년 7월 24일
Dear all, I have a loop that generates 30 matrices, each matrix represents some Y outputs to be plotted in a graph, how can i plot the 30 matrices on the same plot ? my code is
P_Single{K} = Values_S;
figure
plot(P_Single_9_jan{K})
but this code generates 30 graphs which i do not need. i want them all on the same graph please
  댓글 수: 1
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2018년 7월 24일
with a title please for each matrix number, from 1 to 30

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

채택된 답변

Krithika A
Krithika A 2018년 7월 24일
Use the function matlab function "hold on", eg.,:
x = [1 2 3]
y = [4 6 7]
z = [7 8 9]
figure
plot(x,y)
hold on
plot(z)
For further info, see: https://uk.mathworks.com/help/matlab/ref/hold.html
  댓글 수: 3
Krithika A
Krithika A 2018년 7월 24일
It might be better to do a for loop. Eg.,
for i = 1:30
plot(x(i));
xlabel('X axis title');
ylabel('Y axis title');
hold on
end
title('Title')
You'll want to change the code depending on your data structure, but this might be a start
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2018년 7월 24일
IT WORKED THANK YOU VERY MUCH

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by