datetimeの秒​数をcsvに保存する​方法について

21 visualizzazioni (ultimi 30 giorni)
denpika
denpika il 14 Gen 2019
Commentato: denpika il 15 Gen 2019
添付図1のようなcsvファイルを作成したいのですが、添付図2のように日付の秒数が保存できません。どういった方法があるでしょうか?
コードは次のように書いています。
label = {'Date','Data'};
temp = [1;2];
y = [2019 2019];
m = [1 1];
d = [15 15];
h = [8 8];
mi = [10 10];
s = [5 15];
date = (datetime(y,m,d,h,mi,s)).';
csvwrite('filename.csv',[1 1]);
xlswrite('filename.csv',label);
xlswrite('filename.csv',temp,1,'B2');
xlswrite('filename.csv',cellstr(date),1,'A2');
sample.png

Risposta accettata

Jiro Doke
Jiro Doke il 15 Gen 2019
table 型と writetable を使うとうまくいきます。
dd = table(date,temp,'VariableNames',{'Date','Data'});
writetable(dd,'test.csv')
date_csv.png
  1 Commento
denpika
denpika il 15 Gen 2019
ご回答ありがとうございます。追加の質問なのですが、添付図のように単位やコメントをデータラベルに追加したいのですが、何か方法はあるでしょうか?
sample2.png

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 日付と時刻 in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!