Hi everyone, Can anybody help me to plot ??

1 次查看(过去 30 天)
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.

采纳的回答

Geoff Hayes
Geoff Hayes 2015-11-7
编辑:Geoff Hayes 2015-11-7
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 个评论
Add
Add 2015-12-14
Thanks mate. I appreciate your work. Here, as you have introduced breaks in colour at the 1/4th size of the block, how can I give the colour to it as time in the 1st column changes from one whole digit to the next, i.e.. 18 to 19, 19 to 20....and so on. Simply, How to introduce breaks acccordingly to a change in time ??
Geoff Hayes
Geoff Hayes 2015-12-14
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.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by