Hi everyone, Can anybody help me to plot ??
2 views (last 30 days)
Show older comments
The data I am using has 21 columns, the 1st column is Time in seconds. The sampling rate is 0.33 sec. I have data for four hours. The rest 20 columns are data values corresponding to the Time. I want to plot each of the 20 columns corresponding to the time in one figure to see the trend in them, if any. How do I do it ?? I also want to give color to the data for each hour.
0 Comments
Accepted Answer
Geoff Hayes
on 7 Nov 2015
Edited: Geoff Hayes
on 7 Nov 2015
Adarsh - do you really want to give colour for each hour? Wouldn't you rather have colour for each of the 20 columns of data and see how they vary over time?
You can try the following to load your data and plot it
myData = xlsread('pbri_Oct1-20.xlsx');
plot(myData(:,1),myData(:,2:end),'.');
In the above, we read the data from the Excel file and then plot each of the 20 columns versus time (column one) in one call to plot. Each column is assigned a different colour and you can a trend for each in the plot.
You may instead want to create four separate plots for each hour of data.
4 Comments
Geoff Hayes
on 14 Dec 2015
Since the first column corresponds to time, then use the floor function to round down each real number to the nearest integer that is less than or equal to that value. i.e.
timeValues = floor(myData(:,1));
Now timeValues is an array of integers and you are interested in whenever there is a change. So use diff to determine a difference from one integer to another
timeChangesIdcs = find(diff(timeValues)~=0) + 1;
Using find we are able to get the those indices of where a change in time occurs. (A one is added because the array returned from diff has one less element than timeValues due to the nature of that function.)
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!