How to continuously real-time plotting graph from arduino to matlab (10k Variable Resistor)

조회 수: 8 (최근 30일)
Hello and good day to all the experts and visitors of Mat-Lab, I am a mechatronic student and now facing problem trying to interface matlab and arduino..
I am trying to real-time plotting graph from arduino to matlab with (10k variable resistor), but the graph will stop plotting after reach the Maximun X-axis (I set 0-1000).
Can it continuously real-time plotting the graph non stop? full of appreciation or teaching me to solve it.
the code is shown below:
a = arduino('COM3');
interv = 1000;
passo = 1;
t=1;
x=0;
while(t<interv)
b=a.analogRead(0);
x=[x,b];
plot(x);
axis([0,interv,0,1024]);
grid
t=t+passo;
drawnow;
end
  댓글 수: 1
Kerone  Naidoo
Kerone Naidoo 2017년 3월 8일
Hi,
just dont bound the axis, remove the bounds on the axis and that should allow it to continually plot the voltage.

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

답변 (6개)

David Sanchez
David Sanchez 2013년 8월 13일
You just have to change the axis when the highest value is reached:
axis([interv,2*interv,0,1024]); % adapt values to your needs
  댓글 수: 1
Charles Lim
Charles Lim 2013년 8월 16일
Very Thank you for replied
I set interv = 1000
after I change this code
the x-axis started from 1000 to 2000
how do I start from 0 - 1000 after the highest value is reached auto start from 1000 - 2000 , continuously non stop ?

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


anand
anand 2016년 12월 22일
just make use of while(1) after a = arduino and at the last make use of a end function this solves your problem

Sanjay Raam
Sanjay Raam 2014년 2월 9일
편집: Sanjay Raam 2014년 2월 9일
you need not set axis between 0to1024
instead give the following statement
axes auto;
by the way, thanks for your program... it was useful for me to learn!!

khoulod ghanem
khoulod ghanem 2015년 9월 28일
I am trying to plot current-voltage curve from Arduino to Matlab , can you help me to start ??

ravi kumar
ravi kumar 2017년 2월 2일
This did not work for me. I tried this one: Real Time Analog Voltage in Matlab using Arduino it uses line function. anybody knows how to scroll the time line?
  댓글 수: 1
prasad noolu
prasad noolu 2017년 8월 17일
편집: prasad noolu 2017년 8월 17일
try this code: clear all
a = arduino
x = 0;
for k = 1:1000
b = readVoltage(a, 'A0');
x = [x, b];
plot (x);
grid;
drawnow;
end

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


Madhu Govindarajan
Madhu Govindarajan 2017년 10월 17일
Checkout this video - https://www.mathworks.com/videos/plotting-live-data-of-a-temperature-sensor-using-arduino-and-matlab-121317.html?s_tid=srchtitle
HTH, Madhu

카테고리

Help CenterFile Exchange에서 MATLAB 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