do not figure out errors in xlim

3 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2021 年 7 月 30 日
コメント済み: Walter Roberson 2021 年 8 月 1 日
z1=datenum(T.Date(1,:))
z2=datenum(T.Date(height(T.Date),:))
xlim([z1 z2])
Error using xlim (line 31)
Limits must be a 2-element vector of increasing datetime values
I am not sure of the error because z1 and z2 returns values and z1 <z2. Please advise.
  2 件のコメント
Matt J
Matt J 2021 年 7 月 30 日
編集済み: Matt J 2021 年 7 月 30 日
Please run your code within the post and demonstrate that z1 and z2 are legitimate.
Yazan
Yazan 2021 年 7 月 30 日
編集済み: Yazan 2021 年 7 月 31 日
Are you sure z1 and z2 are of size 1x1 (i.e., z1 and z2 are scalars)?

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 30 日
z2 is the last entry from z1. The last entry from an array cannot be strictly greater than the array: it is guaranteed to equal one entry of the array.
Therefore, z1<z2 is not strictly true.
Furthermore because z1 includes z2, if z1 has more than one entry then [z1 z2] would be at least 3 elements if z1 is a row vector, and an error if z1 is a column vector. We can tell from your indexing that if z1 is nonscalar then z1 would be a column vector.
The only way you can reach the xlim is if z1 is scalar and is exactly the same as z2, which would fail the requirements that the values must be increasing.
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 1 日
You are using datenum (numeric) limits on a plot that used datetime (oop object) values.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by