以下のプログラムでx軸に時間y軸に1.txtに入っている気温データをグラフに出したいと考えています。 以下のプログラムでx.TimeInfo.Increment = の値の設定方法(3時間毎),またx.Name = 'Daily Count', x.TimeInfo.Units = 'days'にエラーが出てしまったのですが何かアドバイス頂けると幸いです。
filename =('1.txt');
x = load(filename);
x.Name = 'Daily Count';
x.TimeInfo.Units = 'days';
x.TimeInfo.StartDate = '04-06-01 00:00'; % Set start date.
x.TimeInfo.Format = 'yy-mm-dd HH:MM'; % Set format for display on x-axis.
x.TimeInfo.Increment =
x.Time = x.Time - x.Time(1); % Express time relative to the start date.
plot(x)
エラー
>> test
Field assignment to a non-structure array object.
Error in test (line 3)
x.Name = 'Daily Count';

 Réponse acceptée

michio
michio le 6 Nov 2016

3 votes

TimeInfo プロパティの設定をされているということで、 timeseries オブジェクトの作成 をお考えかと推測します。
x = load(filename);
だけの実行ですと、変数 x は double 型の変数で 1.txt から数値の羅列を読み取っただけです。ですので、ご所望の処理にはおそらく読み取ったデータを timeseries に変換する必要があります。
x = load(filename);
x = timeseries(x);
と一行加えてみてください。

4 commentaires

Naoki Ishibashi
Naoki Ishibashi le 6 Nov 2016
ご回答頂きありがとうございます。 ご指摘頂いた内容追加することで上記のエラー解消されました。 ただやはり私の望む上がり幅でなくそこを指定したいのですが、
x.TimeInfo.Increment =
で設定可能と考えているのですが、時間の指定うまく行きません。 もしご存知でし教えて頂けると幸いです。 2004-06-01 00:00~2004-08-31 21:00で3時間毎に時間を刻みたいです。
michio
michio le 6 Nov 2016
x.TimeInfo.Units = 'hours';
x.TimeInfo.Increment = 3;
で3時間毎の時刻になると思います。いかがでしょう?
Naoki Ishibashi
Naoki Ishibashi le 6 Nov 2016
いつも本当にありがとうございます。 ご教授頂いた内容でうまくできました。
michio
michio le 6 Nov 2016
よかったです。Accept も頂きありがとうございます。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by