필터 지우기
필터 지우기

how to plot a graph gradually?

조회 수: 27 (최근 30일)
Saad Rana
Saad Rana 2021년 6월 13일
댓글: Saad Rana 2021년 6월 13일
Hello everyone,
I am trying to gradually plot a graph as if its plotting in real time. I have tried a code but it doesn't seem to work saying Subscript indices must either be real positive integers or logicals.
Here's my code:
clc
a = 0:0.1:10;
x = sin(2*pi*3*a);
for i = 0:1:100
plot(a(i),x(i))
pause(1)
end
can anyone help me with this?

채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 13일
a = 0:0.1:10;
x = sin(2*pi*3*a);
for i = 1:length(a)
plot(a(1:i),x(1:i))
pause(1)
end
However I recommend that you read about animatedline()
  댓글 수: 1
Saad Rana
Saad Rana 2021년 6월 13일
Thanks A lot. It worked fine

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by