I want to see the text & strings in a single line of Xlabel

4 ビュー (過去 30 日間)
SA
SA 2021 年 3 月 30 日
コメント済み: Star Strider 2021 年 3 月 30 日
Hi,
I wish to see the text and string in a single line as
"Timeseries 2019-09-04T14:53:20 to 2019-09-04T15:10:00".
But I get the xlabel as 4 lines (4 different array) as
"Timeseries
2019-09-04T14:53:20
to
2019-09-04T15:10:00"
xlabel(['Timeseries' string(timestamp(end-1)) 'to' string(timestamp(end))]);
Can anybody pull me out from here? Thanks in advance

採用された回答

Star Strider
Star Strider 2021 年 3 月 30 日
Try this:
timeseries = ['2019-09-04T14:53:20';'2019-09-04T15:10:00']; % Create Array
xlabel(sprintf("Timeseries %s to %s", string(timeseries(end-1:end,:))))
.
  4 件のコメント
SA
SA 2021 年 3 月 30 日
I just finished the comment thanking you @VBBV
"The interesting thing is that 'Star Strider' he used the array which also works! So, both answers are correct."
Now, I'm confused which answer need to be accepted?
Thanks both of you.
Star Strider
Star Strider 2021 年 3 月 30 日
For my part, my pleasure!

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

その他の回答 (1 件)

VBBV
VBBV 2021 年 3 月 30 日
%if true
xlabel(['Timeseries' num2str(timestamp(end-1)) 'to' num2str(timestamp(end))]);
Use num2str
  5 件のコメント
VBBV
VBBV 2021 年 3 月 30 日
編集済み: VBBV 2021 年 3 月 30 日
In that case convert timeseries to cell array as shown below and access the first and last values as below
%if tru
T = cellstr(timeseries);
xlabel(['Timeseries', T{1}, 'to',T{end}])
SA
SA 2021 年 3 月 30 日
編集済み: SA 2021 年 3 月 30 日
This time it works! The interesting thing is that 'Star Strider' he used the array which also works! So, both answers are correct. Now, I'm confused which answer need to be accepted?
Thanks both of you.

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by