Write pre-existing variable names and their values to excel
古いコメントを表示
Hi Everyone,
I have a function that outputs a ton of variables, which all have useful names and numeric values.
I want to write the existing variable name to column 1 and the associated variable data to column 2, is this possible?
I've seen some xlswrite code examples, but none where the variable name and it's data are split before entry into the xls.
Cheers Nick
採用された回答
その他の回答 (3 件)
Pawel Jastrzebski
2018 年 2 月 12 日
If your variables are all numeric then consider the following code:
% create variables
a = 5;
b = 10;
c = 15;
d = 0;
d1 =1;
% get names
z_names = who;
% put names in the table
t = table(z_names);
% get values
z_values = [a b c d d1]';
% add values to the table
t.val = z_values;
% write table to excel
writetable(t,'excel.xlsx');% get values
z_values = [a b c d d1]';
t.val = z_values;
% write to excel
writetable(t,'excel.xlsx');
Nick Burnham
2018 年 2 月 12 日
1 件のコメント
Pawel Jastrzebski
2018 年 2 月 12 日
That message probably means that you're trying to add/create a new column in the table by using a row vector. If that's the case, transpose it first.
Nick Burnham
2018 年 2 月 12 日
編集済み: Stephen23
2018 年 2 月 12 日
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!