フィルターのクリア

How to plot waterfall for datetime array

8 ビュー (過去 30 日間)
Hyeon Jun Kim
Hyeon Jun Kim 2018 年 6 月 22 日
編集済み: Chenghao 2023 年 3 月 12 日
I would like to plot waterfall, r, as a function of datetime. The waterfall code is:
waterfall(frequency, datetime, value)
where 'datetime' have format 'HH:mm:ss'
But, Running this code, plotting error message Doesn't waterfall function support "datetime" format?
  2 件のコメント
KSSV
KSSV 2018 年 6 月 22 日
YOu have to plot with indices first and then use datetick
KAE
KAE 2020 年 5 月 15 日
編集済み: KAE 2020 年 5 月 15 日
KSSV, can you please show how to do this starting with the code below?
% Make a time vector for x-axis
t1 = datetime(2020,1,1);
t2 = datetime(2020,12,31);
t = t1:t2;
nTime = length(t);
dayOfYear = day(t,'dayofyear');
% Make a y vector for y-axis
y = 1:100;
nY = length(y);
% Get z values at x and y from peaks function
z = peaks(nTime);
z = z(1:nTime, 1:nY,:)'; % Trim so dimensions are correct
f1 = figure;
w = waterfall(1:nTime, y, z);
datetick('x'); % Seems to assume the tick spacings are days
% How to get x-tick labels to correspond to actual date values in vector t?
% Should we plot with dayOfYear instead of 1:nTime

サインインしてコメントする。

回答 (1 件)

Chenghao
Chenghao 2023 年 3 月 9 日
編集済み: Chenghao 2023 年 3 月 12 日
Please try the follwoing code:
waterfall(frequency, 1:numel(datetime), value)
yticklabels(categorical(datetime));

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by