HOW CAN I DO A CONTINUOUSLY MATLAB GRAPH AUTO UPDATABLE

1 回表示 (過去 30 日間)
Gerard Nava
Gerard Nava 2018 年 6 月 4 日
編集済み: Gerard Nava 2018 年 6 月 4 日
I am adquiring data from arduino, froman ultra sonic sensor and from de position of a servo motor , i have two variables i have a huge problem ..well two
first i need to plot in real time, i did it, but i run the program, then it plots, then restarts the program and so the counter in x axis , i have red other old post about this , but ,i just dont get it, i need two graph "current_pos", and "t"
Second after that i need to derive current_pos to get its velocity, and then derive it again to get acceleration , is that even possible? to differentiate or derive an input in order to get another physic analysis?, if so , it would be current_pos, Vel=[diff(current_pos)]; Accel=[diff(Vel)]; -- i did it and didnt worked -- please help i needed for tomorrow morning %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a = arduino ('COM3', 'Uno', 'Libraries',{'Servo','JRodrigoTech/HCSR04'} );
s = servo(a, 'D4')
sensor = addon(a, 'JRodrigoTech/HCSR04', 'D12', 'D8')
clear s;
s = servo(a, 'D4', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', 2300*10^-6)
for i=1:1
writePosition(s,0);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1);
writePosition(s,0.5);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1);
writePosition(s,1);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1); end %%%%%%%%%%%%%%%%555
  2 件のコメント
Gerard Nava
Gerard Nava 2018 年 6 月 4 日
編集済み: Gerard Nava 2018 年 6 月 4 日
i did this ...
init_time=1
interv=3
x=0
while(init_time<interv)
b=current_pos;
x=[x,b];
plot(x)
grid ON
init_time=init_time+1;
drawnow
-.................... didnt worked
i want to reach here:
V=[ diff(t)]
A=[ diff(V)]
W=[ diff(current_pos)]
ALP=[ diff(W)]
subplot(3,2,1),plot(t,'k'),ylabel('Posición '),xlabel('Tiempo'),title('Grafica de posición s','FontSize',12)
subplot(3,2,3),plot(V,'g'),ylabel('Velocidad '),xlabel('Tiempo'),title('Grafica de Velocidad s','FontSize',12)
subplot(3,2,5),plot(A,'r'),ylabel('Aceleración '),xlabel('Tiempo'),title('Grafica de Aceleración s','FontSize',12)
subplot(3,2,2),plot(current_pos,'g'),ylabel('Posición '),xlabel('Tiempo'),title('Grafica de posición Angular', 'FontSize',12)
subplot(3,2,4),plot(W,'c'),ylabel('Velocidad '),xlabel('Tiempo'),title('Grafica de Velocidad Angular', 'FontSize',12)
subplot(3,2,6),plot(ALPHA,'r'),ylabel('Aceleración'),xlabel('Tiempo'),title('Grafica de Aceleracón Angular', 'FontSize',12)
ti=ti+pass drawnow
But with no reset on x axis, like from 0 to 10 and then reset, my gram using the first program of my comment ,( first adquires and writes data then graph then reset )ETC. over and over, i want to write , read data and continuously graph data is that possible?
sloppydisk
sloppydisk 2018 年 6 月 4 日
First of all these links maybe useful

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLEGO MINDSTORMS EV3 Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by