Unable to perform assignment because dot indexing is not supported for variables of this type.

5 ビュー (過去 30 日間)
Amelia
Amelia 2023 年 11 月 4 日
編集済み: Arun 2024 年 1 月 4 日
Hello everyone.
There is the code that I want to use, but there is still error with it. How can I fix it?
AUTHMET.Hour.Format= "HH:00"
writetable (AUTHMET, '20230205_AUTHMET_hourly.txt')
  3 件のコメント
Amelia
Amelia 2023 年 11 月 5 日
Yes, it should be time
Walter Roberson
Walter Roberson 2023 年 11 月 5 日
Put a breakpoint in the code and run to there. show us
classs(AUTHMET)
class(AUTHMET.Hour)
There is a chance that one of those two is [] the empty array

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

回答 (1 件)

Arun
Arun 2024 年 1 月 4 日
編集済み: Arun 2024 年 1 月 4 日
Hi Amelia,
I understand that you want to set the hour format to “HH:00” for AUTHMET which is a datetime data type.
The setDefaultFormats” property would be useful in this case. Here is a modified code of your implementation that might be useful for your issue:
% sample value for AUTHMET
AUTHMET = datetime('2022-01-01 12:00:23');
% set the format for Hour as hh:00
datetime.setDefaultFormats('default','yyyy-MM-dd hh:00');
%verify the values.
display(AUTHMET.Hour); %Hour value for AUTHMET
12
display(AUTHMET.Year); %Year value for AUTHMET
2022
display(AUTHMET); %Value of AUTHMET
AUTHMET = datetime
2022-01-01 12:00
writematrix(AUTHMET, '20230205_AUTHMET_hourly.txt'); %write the text to the file.
for more information regarding the following topics please refer to the MATLAB documentation links:
I hope this helps.
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 1 月 4 日
Functionality or property might be better fitting to describe "setDefaultFormats"

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by