I want to plot the temperature data coming from serial port per second and time_stamp it in MATLAB, and display the time information on X-Axis.
The data coming from serial port is in string format and after receiving it, i converted it into double and plotted using MATLAB plot function. But i am not able to understand, that how can i time stamp the received data and mention that time on x-axis.
Currently i created a circular array of 100 values, which will be increased later to show more information. My program is as follow:
ser = serial('COM5', 'BaudRate',9600, 'Timeout',10);
DATA_SIZE = 100;
temperature = zeros(DATA_SIZE, 1);
index = 1;
temp = fscanf(ser);
if size(temp) == 
disp 'Timeout Occurs'
disp 'Check Connections'
if index < DATA_SIZE
index = index+1;
index = 1;
temperature(index) = str2double(temp);
title('Real-Time Temperature Plot');
I tried to plot the time value on X-Axis but failed to get the correct output. Please someone help me regarding this. Any other suggestion are also welcomed. Thanks in advance.