Filter löschen
Filter löschen

How to plot a graph with x and y axis input live from two hardware (arduino and laser gauge- UART)

3 Ansichten (letzte 30 Tage)
Hi,
I'm a newbie to matlab. I'm trying to plot a graph where realtime data is received from a laser gauge using serial input (FT232), and pressure reading from a sensor using arduino. I tried to interface both the hardware to arduino but it wasn't an option recommended by the tech for the laser gauge and wasn't working.Serial signal was verified to work with tera term. Now I built up a code to receive that in matlab. I would like some help on how to now integrate that code to plot where the x axis is the source from arduino.
%
close all;
%serial object
s = serialport('COM4','BaudRate',9600);
% open serial port
fopen(s);
%plotting data
i=1;
while (1)
data (i) = str2double(fscanf(s));
if i <= 150
plot(data);
else
plot(data(end-150:end));
ylim([0 5]);
pause(0.01);
i=i+1;
end
  3 Kommentare
Mohammed Ammad
Mohammed Ammad am 13 Nov. 2022
Is it possible to get the data for the x and y axis from the hardware to plot the graph for 7 seconds and then stay idle?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by