필터 지우기
필터 지우기

displaying different length vector by graph

조회 수: 4 (최근 30일)
Ted Erdenekhuyag
Ted Erdenekhuyag 2021년 11월 15일
답변: Star Strider 2021년 11월 15일
y1=[2 5 7]
y2=[1 1 3 4 5 7 8 9]
y3=[2 4 4 7 9]
y4=[2 4 8]
y5=[3]
plot(y1, y2, y3, y4, y5)
this code is indicating error " all vectors must be same length" is there any tip to display this data as one plot
Thank you very much
  댓글 수: 1
Adam Danz
Adam Danz 2021년 11월 15일
What are you trying to achieve? plot(x,y) or plot(x1,y1,x1,y2,...,xn,yn) plots paired coordinates and that requires equal numbers of values in x and y.

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

답변 (1개)

Star Strider
Star Strider 2021년 11월 15일
The only way to do that without using correxponding ‘x’ vectors is to plot them in a loop —
y1=[2 5 7];
y2=[1 1 3 4 5 7 8 9];
y3=[2 4 4 7 9];
y4=[2 4 8];
y5=[3];
ym = {y1,y2,y3,y4,y5}; % Create Cell ARray
figure
hold on
for k = 1:numel(ym)
plot(ym{k},'.-') % Plot With Markers
end
hold off
grid
legend('y1','y2','y3','y4','y5', 'Location','best')
.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by