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

답변 (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

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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

질문:

2022년 6월 27일

댓글:

2022년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by