MATLAB Answers

how do i live plot 3 different values?

2 ビュー (過去 30 日間)
Orel Levy
Orel Levy 2019 年 9 月 9 日
コメント済み: Orel Levy 2019 年 9 月 15 日
I have an angular velocity signal and i want to plot it live on the same plot around all 3 axes. meaning in each step i want the X axis to move one time step and the Y axis to update wx,wy,wz of said step.
I am currently using animted line, but it updates only 1 value for y axis each time step.
my code is:
H=figure('name','gyro measured');
hold on
grid on
xlabel('Time [sec]')
ylabel('[deg/sec]')
title('measured angular velocity')
sparse_time=0.2;
H = animatedline('marker','.');
for i=1:numel(w_meas)
tic
timer = i*sparse_time;
addpoints(H,times(20*i-19),w_meas(20*i-19,1),w_meas(20*i-19,2))
drawnow limitrate
legend('w_x','w_y','w_z')
calc_time = toc;
pause(0.2-calc_time)
end
drawnow

  1 件のコメント

Rik
Rik 2019 年 9 月 9 日
Use the output of the plot function to set the XData and YData properties directly inside your loop. The same might be possible with animatedline, read the doc to see if that is possible.

サインインしてコメントする。

回答 (1 件)

Neuropragmatist
Neuropragmatist 2019 年 9 月 10 日
Can you be more precise in what you want to achieve? For example, here is the Matlab help example given for animatedline:
numpoints = 100000;
x = linspace(0,4*pi,numpoints);
y = sin(x);
figure
h = animatedline;
axis([0,4*pi,-1,1])
for k = 1:numpoints
addpoints(h,x(k),y(k))
drawnow update
end
What do you need to do differently to this? It sounds like you have 3D data but you want the x-axis to move? Does that mean one of your variables is time?
Thanks,
NP.

  1 件のコメント

Orel Levy
Orel Levy 2019 年 9 月 15 日
I wanted to use the animatedline function to add 3 different Y values in each step, which are wx,wy,wz.
I eventually used Rik's anwer and didn't use animatedline at all, which works perfect.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by