How to change time, read and graph in MATLAB?

3

I am a student of meteorology and analyze data from micrometeorological towers. In each line of my file, .csv has tower code, year, julian day, and minute time. 110.2015,005.2359

1st I would like to know how to set my schedule from 2359 to 23:59. 2º Plot a chart and in my Xlabel have the time and that this time on the x axis is dynamic to my zoom (if necessary).

    
asked by anonymous 17.02.2016 / 19:07

1 answer

1

Well come on, having the time in decimal can be something interesting (smart), this can help you in dynamic visualization on the x axis during zooming:

An example:

max=33;
min=15;

t=(0:100:2359)

r1 = min + (max-min).*rand(length(t),1);

plot(t,r1)

We are not provided with all the information, so the above code tries to simulate the data for demonstration, I am randomly generating temperature values between 15 and 33 degrees in variable r1 , we also have no idea of what is your sample window, then again I can only simulate, the t variable linearly generates the time in decimal from 0 to 2359 , that is 24 hours spaced from 1 to% (sample window), this window is how long the measurements are taken, this code returns the following plot:

Withazoom:

Noticethatthe1axisdynamicallydisplaysthevaluesdecimally.

OK,youdonotwantthetimevaluetobedecimal,soyouwilllosethemomentumwhenyouzoomin(obviouslythetimeformatisastringandnotanumber),well,seehowtosetthetimeintheconventionalformat:/p>

%emminutostempoamostragem=60;max=33;min=15;dv=0/24:(0.0666666666667*tempoamostragem)/96:23/24+4/96;labelX=datestr(dv,'HH:MM');labelX=cellstr(labelX);r1=min+(max-min).*rand(length(labelX),1);t=(1:1:length(labelX));plot(t,r1);set(gca,'XTick',1:length(labelX),'XTickLabel',labelX);

Explainingsomecodedetails:

ThevariableXalreadysayseverythingishowlongthecollectionwasdone,I'musingthematlabfunction datestr to generate a time vector, the function uses as input another vector ( tempodeamostragem ) spaced linearly by the sampling time for a 1 day converted to the fourth dv , the value 24*4=96 is equivalent to 1 minute in this new format:

>> 24*60

ans =

        1440

>> 96/1440

ans =

    0.0667

Proving if it's really true:

>> 0.0666666666667*24*60

ans =

   96.0000

Perfect, after all this juggling, matlab will return a vector with the time in conventional format and we can use this variable within 0.0666666666667 .

Plots:

WithZoom:

In reality it is very difficult to try to help you without having the data and a concise explanation of what you need, just talking XTick is not enough so that we can help you with exactness, in your question for example, we do not know of which temperature data, we do not know if your samples are fixed or can vary (every 5 minutes or you can change to 10 minutes for example), we can but we need you to describe and present all the information available.

    
17.04.2016 / 05:29