How to save tables in txt or xls file?

2 ビュー (過去 30 日間)
Stefano Cucchi
Stefano Cucchi 2022 年 2 月 1 日
回答済み: KSSV 2022 年 2 月 1 日
Hello,
i need to save tables into txt or xls file. That's the script:
  • %Create a "unique name" for the file
  • nrdm1={'File_Log_'};
  • lettere='A':'Z';
  • nrdm2=lettere(randi(numel(s)));
  • nrdm3=lettere(randi(numel(s)));
  • nrdm4={'.txt'};
  • name_file=strcat(nrdm1,nrdm2,nrdm3,nrdm4); %example: "File_Log_NX.txt"
  • %Create tables (tab1, tab2, tab3)
  • NomeDati = ["Frequenza di campionamento [Hz]";"Numero Canali [ ]";"Tempo di acquisizione [s]";"Blocco PSD [s]";" TF [s]"];
  • Valori=[Fs;n_canali;time_end;Tb;Tbd]; %variables
  • tab1 = table(NomeDati,Valori)
  • Warning = ["Warning valore medio";"Warning rumore"];
  • NomeCanale=["Rilevato";"Non rilevato"];
  • tab2 = table(Warning,NomeCanale)
  • NumeroCanale = ["1","2"]';
  • nome_canali=["fds","hgf"]';
  • tab3 = table(NumeroCanale,nome_canali)
  • %Save the file
  • save(name_files,'tab1','tab2','tab3','-ascii')
Of course it can't work properly ("Error using save: Must be a string scalar or character vector."). I tried also "writetable" or "xlswrite" but i don't know how to organize these datas and saving the file with the right name.
Anyone can help?

回答 (1 件)

KSSV
KSSV 2022 年 2 月 1 日
Read about writetable.

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by