Display image with 3 variable from abundance of excel data.

1 次查看(过去 30 天)
Dear community,
My data as attached is in every minute in every day of January 2014 from 31 different of observer (PRN). My variables I want to tackle are Day, Time and VTEC.
First, I need to find rate of change of the VTEC (ROV) within intervals of 1 minute for two cases (i) all PRN, (ii) individual PRN.
Then, I need to find the index for ROV (ROVI) by the standard deviation of the ROV in a five-minute interval also for both cases (i) all PRN, (ii) individual PRN.
Finally, I want to display the image of Time (x), Day (y) and ROVI and yes for both cases (i) all PRN, (ii) individual PRN.
If you asked me whether I already tried or not. The answer is yes (may refer my questions' asked) but I made in seperate code means calculate ROV one .m, ROVI another .m and I find it inconvenience for me. Furthermore, I encounter problem to do the image because of the ROVI value some is NaN and even in imaginary number. Hence, I also worry that what I've done from the start is completely wrong to what should be calculated.
I would be greatful if anyone could help settling this lingering problem.
  5 个评论
Cris LaPierre
Cris LaPierre 2021-1-9
编辑:Cris LaPierre 2021-1-9
You are getting complex numbers because you are taking the square root of negative numbers (some of your differences are negative). You can use either real or abs to extract the real part or compute the magnitude of your complex numbers (respectively).

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2021-1-9
编辑:Cris LaPierre 2021-1-10
I'm not familiar with the processing steps for this type of data, but here's a modified version of your code that creates the image. Remember, an image is a matrix. Your code is creating a vector.
There were some other mistakes in your code as well as unnecessary code. I've made changes (including removing the diff so sqrt is not complex) to create something that works. No claims to it being correct.
%___Read data___%
data = readtable("Book_A.xlsx");
%___Convert DAY and TIME into durations___%
data.DAY = days(data.DAY);
data.TIME = days(data.TIME);
%___Create a datetime___%
data.TimeStamp = datetime(2014,01,01) + data.DAY-1 + data.TIME;
data.TimeStamp.Format = "MM-dd-yy HH:mm";
%___Convert the table to a timetable___%
dataTT = table2timetable(data,"RowTimes","TimeStamp");
%___Use retime to average the PRN data into 1 or 5 minute increments___%
PRNTT1min = retime(dataTT(:,"VTEC"),"minutely","mean");
PRNTT5min = retime(dataTT(:,"VTEC"),"regular","mean","TimeStep",minutes(5));
%___Calculate ROV 5 minute in second or minute___%
ROV_5min = PRNTT5min.VTEC/5;
ROVI_Jan = sqrt( ROV_5min );
ROVI_Jan(isnan(ROVI_Jan))=0;
ROVI_all = reshape(ROVI_Jan,24*60/5,[])';
%___Display image___%
imagesc(ROVI_all);
caxis([0.0 1.0]);
colorbar;
colormap(jet)
%___Axes properities___%
set(gca,'FontSize',10);
xlabel('Coordinated Universal Time, UTC (hr)');
set(gca,'xTick',0:24:288);
set(gca,'xTickLabel',{ '0', '2', '4', '6', '8', '10', '12', '14', '16', '18', '20', '22','24'});
ylabel('Day of Month (DOM)');
set(gca,'yDir','normal')
set(gca,'yTick',0:5:31);
title({'Rate of change of VTEC index', '1 to 31 January 2014'},'FontSize',15);
  1 个评论
Ann
Ann 2021-1-10
编辑:Ann 2021-1-10
OH GOSH!!! Yours is perfectly perfect! I literaly crying after run the code.
I just noticed by removing the diff then divide with 5 minutes already answering the rate of change. I think I am completely clueless that time yea why should I do some diff to get the rate of change.
I am forever indebted to you, thank you so much, Cris!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by