plotting many things in one window

조회 수: 9 (최근 30일)
cgo
cgo 2015년 1월 6일
댓글: Star Strider 2015년 1월 7일
Hi,
I have X, which is a 100x100 matrix. I would like to plot each row with respect to the integers 1:100. Of course I could write the following:
Plot(1:100, x(1,:), 1:100, x(2,:), ....)
Is there a shorthand to this ? Thanks

채택된 답변

Star Strider
Star Strider 2015년 1월 6일
One options is to just give it your vector and the matrix:
x = linspace(0,99);
y = rand(100,100);
figure(1)
plot(x, y)
grid
Another option is the ribbon function.
  댓글 수: 2
cgo
cgo 2015년 1월 7일
I'm afraid this situation is a little bit too simplistic. So I will have to ask again.
This time, my matrix A is of size n x 100. I want to plot each row of the matrix vs an independent variable t = 1:100.
For example, if I have infinite time, then I will write it as
Plot(t, A(1,:), t, A(2,:), t, A(3,:)…)
I can't figure out how to write it in short hand, if A is not a square matrix. Thanks
Star Strider
Star Strider 2015년 1월 7일
The matrix doesn’t have to be square. MATLAB will plot it correctly so long as one of its dimensions matches the length of your ‘x’ vector:
t = 1:100;
y = rand(50,100);
figure(1)
plot(t, y)
grid

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by