matlab plot in real time

조회 수: 3 (최근 30일)
jianlong huang
jianlong huang 2015년 12월 11일
댓글: Geoff Hayes 2020년 5월 7일
just a really simple problem, how can I plot this diagram in real time. I want those red crosses plotted on to my graph one by one rather than all of them at the same time.
A=[1:10];
B=[1:10];
B=0;
for B=[1:10]
temp=A(B);
B2=num2str(B);
disp(['Reading number=',B2,'temperature=',temp2])
plot(A,'rx')
pause(0.2)
end

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 12월 11일
jianlong - try using the hold on command to retain the current plot when adding new ones. For example
hFig = figure;
hold on;
A=[1:10];
for k=1:10
disp(['Reading number=',k,'temperature=',A(k)])
plot(k,A(k),'rx')
pause(0.2)
end
Note how I have removed the B and the temporary variables and just access the element of A on the kth iteration as A(k).
  댓글 수: 2
jianlong huang
jianlong huang 2015년 12월 11일
what is hFig=figure; means :( i am just start to use matlab 3 days ago
Geoff Hayes
Geoff Hayes 2015년 12월 11일
With
hFig = figure;
I am just creating a figure (to draw your plot on) and storing its handle in hFig. It isn't necessary for the above example, but if you need that handle for further processing then you have it ready to use.

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

추가 답변 (2개)

Joseph Cheng
Joseph Cheng 2015년 12월 11일
no idea what you're doing with A or B especially with defining B but then using it as the indexer in the for loop but get what you can from the example:
A=[1:10];
figure(1),hold on,axis([0 10 0 10])
for ind=[1:10]
plot(ind,A(ind),'rx')
pause(.1)
end

anil simsek
anil simsek 2020년 5월 6일
I have Arduino code, I want to draw it instantly in matlab. Can you help me ?
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2020년 5월 7일
anil - you will need to post some of your code so we can get an idea of what you are attempting. Also,this isn't an answer to the original question so please delete and add as a comment or create your own question.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by