i need to plot data with two columns; one timestamped and two measurments in matlab

To plot data with two columns, one timestamped and two measurements using MATLAB, you can follow the steps below:

  1. Load the data into MATLAB
main.m
data = load('datafile.csv') %Load the data from a CSV file
59 chars
2 lines
  1. Store the first column as a datetime object and the second and third columns as measurement variables
main.m
timestamp = datetime(data(:,1),'InputFormat','yyyy-MM-dd HH:mm:ss'); %Convert the first column to datetime
measurement1 = data(:,2); %Store the second column as measurement 1
measurement2 = data(:,3); %Store the third column as measurement 2
242 chars
4 lines
  1. Use one of the plot functions available in MATLAB to plot the data
main.m
plot(timestamp, measurement1) %Plot the first measurement against time
hold on % Allow multiple lines to be plotted on the same graph
plot(timestamp, measurement2) %Plot the second measurement against time on the same graph
xlabel('Time') %Add an X-axis label
ylabel('Measurement') %Add a Y-axis label
legend('Measurement 1','Measurement 2') %Add a legend to identify the different lines
388 chars
7 lines

This will produce a plot with two lines; one for each measurement, against the time axis.

gistlibby LogSnag