フィルターのクリア

how to export data into text file

4 ビュー (過去 30 日間)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2019 年 4 月 4 日
コメント済み: Peter Perkins 2019 年 4 月 8 日
Dear All, I am trying to export my output data from MATLAB into a text file, I attached a sample of the required FORMAT for the output file, and also the code I wrote to form the table, how can I please make it look like the output file I attached? Thank you
Month = {'January';'January';'January';'January';'January';'January';'January';'January';'January';'January'};
Class = [4;5;6;7;8;9;10;11;12;13];
Total = [100;100;100;100;100;100;100;100;100;100;];
Single = [Values_S_C4';Values_S_C5';Values_S_C6';Values_S_C7';Values_S_C8';Values_S_C9';Values_S_C10';Values_S_C11';...
Values_S_C12';Values_S_C13'];
T = table(Month,Class,Total,Single)
writetable(T,'tabledata.txt');
type tabledata.txt

採用された回答

Guillaume
Guillaume 2019 年 4 月 4 日
Assuming that your Values_S_Cx vectors were column vectors so that Single is a numel(Total) x Ncolumns matrix, then:
writetable(T, 'tabledata.txt', 'WriteVariableNames', false);
If using R2019a, you could store your data in a cell array instead of a table, and then use writecell instead.
C = [Month, num2cell([Class, Total, Single])];
writecell(C, 'tabledata.txt');
Note that you should never create numbered or serially named variables such as your Values_S_Cx. They should have been stored straight away as just one variable.
  6 件のコメント
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2019 年 4 月 4 日
What is your suggestion please?
Peter Perkins
Peter Perkins 2019 年 4 月 8 日
A table, or a timetable, probably containing a mix of numeric and categroical variables.

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

その他の回答 (0 件)

カテゴリ

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