Xlim with datetime removing plotted data

9 ビュー (過去 30 日間)
Dan Strawbridge
Dan Strawbridge 2022 年 10 月 10 日
回答済み: Walter Roberson 2022 年 10 月 10 日
With the Xlim line excluded it plots the data correctly, but whenever I included xlim it removes the plotted line unsure why this is happening?
clear all
T = readtable('ExportedData.csv','PreserveVariableNames',true);
SolarIR = table2array(T(:,7));
time = table2array(T(:,1));
time.Format = 'HH:mm:ss';
plot(time,SolarIR)
ylim([0 800])
xlabel("Time (HH:mm:ss)")
ylabel("Solar Irradiance (W/m^2)")
title("Solar Irradiance")
xlim([datetime('09:59:00') , datetime('10:01:50')])
alt=gca;
alt.XTickLabel=alt.XTickLabel;

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 10 月 10 日
datetime passed only a time makes the times relative to today. Your input data probably has a date other than today. You should use the input datetime and dateshift 'start' 'day' and add duration() to that to get the xlim to use.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by