フィルターのクリア

I have a code for data acquisition n plotting from one sensor how do write the code for three sensors such that I plot three graphs of different color in same figure

1 回表示 (過去 30 日間)
clear all
close all
clc;
a = arduino();
tmax = 50;
figure(1),
grid on,
title('pulse sensor Analog Voltage Real Time Data Graph')
xlabel ('Time (s)'), ylabel('Voltage');
axis([0 tmax+1 -0.5 5.5]);
k = 0;
v = 0;
t = 0;
tic
while toc<= tmax
k = k + 1;
v(k) = readVoltage(a,'A0');
t(k) = toc;
if k > 1
line([t(k-1) t(k)],[v(k-1) v(k)]);
drawnow;
end
end
  3 件のコメント
anil simsek
anil simsek 2020 年 5 月 6 日
I have Arduino code, I want to draw it instantly in matlab. Can you help me
Walter Roberson
Walter Roberson 2020 年 5 月 7 日
The frameworks people have posted should work, provided that you do not need more than about 40 Hz. (But I do recommend animatedline() instead of continually doing line())

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

採用された回答

madhan ravi
madhan ravi 2018 年 12 月 25 日

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 12 月 25 日
line() can accept a 'color' option.
However, it is inefficient to draw a line between every pair of points. You should look at animatedline() which permits you to addpoints()

Amit Kadarmandalgi
Amit Kadarmandalgi 2018 年 12 月 25 日
clear all
close all
clc;
a = arduino();
tmax = 50;
figure(1),
grid on,
title('pulse redings')
xlabel ('Time (s)'), ylabel('Voltage');
axis([0 tmax+1 -0.5 5.5]);
c= 0;
v= 0;
p=0;
k=0;
t = 0;
tic
while toc<= tmax
c = c + 1;
v(c) = readVoltage(a,'A0');
w(c) = readVoltage(a,'A1');
x(c) = readVoltage(a,'A2');
t(c) = toc;
if c > 1
line([t(c-1) t(c)],[v(c-1) v(c)],'color','blue');
hold on
line([t(c-1) t(c)],[p(c-1) p(c)],'color','red');
hold on
line([t(c-1) t(c)],[k(c-1) k(c)],'color','green');
drawnow;
end
end
  1 件のコメント
Amit Kadarmandalgi
Amit Kadarmandalgi 2018 年 12 月 25 日
thanks for the answers .... managed to figure it out this is the code if someone is in a simillar situation

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

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by