How do I limit plotting the values from a row variable say time?

I want to make a plot with the time for 41665 values only. How do I achieve this?
figure('position',[50 100 1400 400])
pcolor(datenum(time),rng,zh)
datetick('x')
shading flat

Respuestas (1)

Z = peaks(30) ;
x = datetime(2022,01,01):datetime(2022,01,30) ; % datetime class
y = 1:30 ;
pcolor(x,y,Z)
shading flat

3 comentarios

Tunde Adubi
Tunde Adubi el 27 de Jun. de 2022
Editada: Tunde Adubi el 27 de Jun. de 2022
Hey, Thanks but I'm still having errors seen below.
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric
arrays. You can also create datetimes from a single numeric array using the 'ConvertFrom' parameter.
How can I correct that so the X-axis of the plot should be limited at '27-Dec-2021 00:00:00'?
time1 = ncread(fname,'time');
units = ncreadatt(fname,'time','units');
year = str2num(units(15:18)); month = str2num(units(20:21));
day = str2num(units(23:24)); hr = str2num(units(26:27));
minutes = str2num(units(29:30));
test_time = datetime(year,month,day,hr,minutes,time1);
time = [time;test_time];
figure('position',[50 100 1400 400])
xtime= datetime(26:12:2021: 00:00:00):datetime(27:12:2021 : 00:00:00);
pcolor(xtime,rng,zh)
What are dimensions of xtime, rng and zh?
The time variable (x-axis) should be 41665x1; The rng is the Y-axis 600 x1(double); zh has no dimension as its a 2D plot, see attached figure. In the attachment, The vertical space on the RHS with an extra hour (00:00 to 01:00) is to be eliminated from time.

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Jun. de 2022

Comentada:

el 28 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by