Hi everyone, Can anybody help me to plot ??

조회 수: 1 (최근 30일)
Add
Add 2015년 11월 7일
댓글: Geoff Hayes 2015년 12월 14일
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