save work space variables into excel sheet headlines and columns

1 回表示 (過去 30 日間)
amjad almaarafawi
amjad almaarafawi 2019 年 12 月 14 日
回答済み: Voss 2024 年 1 月 2 日
Hi, I have a lone code with about 7 variables Im trying to save into excel sheet with the variables names as headline and the data into the column of that headline. all the varables are matrix 20x1 and the names are listed below.
r_coords
extracted_data
r_exper
V_exper
V_interpolation
Absuolut_Error
Relative_Error
filename = (sprintf('monitor_line_%d_ degree %.1fCA_%s', Monitor_line, CrankAngle, upper(variable)));
Results_Names={'r_coords','extracted_data','r_exper','V_exper','V_interpolation','Absuolut_Error','Relative_Error'};
Results_Values=[r_coords,extracted_data,r_exper,V_exper,V_interpolation,Absuolut_Error,Relative_Error];
sheet=1;
xlswrite('filename.xlsx',Results_Values,sheet);
  1 件のコメント
Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2019 年 12 月 17 日
Could you give some information on the issue being faced?

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

回答 (1 件)

Voss
Voss 2024 年 1 月 2 日
One way to write the file:
C = [Results_Names; num2cell(Results_Values)];
writecell(C,filename)
Another way to write the file:
T = array2table(Results_Values,'VariableNames',Results_Names);
writetable(T,filename)
Another (not recommended) way to write the file:
sheet=1;
C = [Results_Names; num2cell(Results_Values)]
xlswrite(filename,C,sheet);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by