how to plots 3 different sensor values seperately in matlab guide?

i am taking 3 input sensor values from the arduino. the code for arduino is
unsigned int pres; unsigned int temp; unsigned int fluidrate;
void setup() {
Serial.begin(9600);
}
void loop()
{
pres = analogRead(0);
temp = analogRead(1);
fluidrate = analogRead(2);
Serial.println(pres);
Serial.println(temp);
Serial.println(fluidrate);
}
i want to plot these values in 3 different axes created in matlab guide.these plot should be in real time.how can i get the sensor data separetely.
the code for single data plot is
obj = serial('COM8'); %creating the object
set(obj,'BaudRate',9600) %setting baudrate
fopen(obj); %open port
set(obj,'terminator','cr') %providing the terminator pressure1=0; % a variable for y axis
time1=now; % time is in x axis % create a graphics object for a particular axes handles.hPlot1 = plot(handles.axes1, NaN, NaN); guidata(hObject, handles);
while 2>1 % infinite loop
time2=now;
x=[time1 time2];
ip_data = fscanf(obj) ;
pressure2= str2num(ip_data) ;
pressure=[pressure1 pressure2];
datetick('x','HH:MM') %change the axis
pause(0.5);
pressure1=pressure2;
time1=time2;
end
end

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by