MATLABで得られ​たデータをExcel​の各シートに名前を付​けて保存したい!

x_data = [1, 2, 3, 4, 5];
y_data = [6, 7, 8, 9, 10];
z_data = [11, 12, 13, 14, 15];
このように3つのデータが得られたとき、その値のそれぞれをExcelのシート別に保存したい。
参考として下図のようなExcelファイルを保存したい。

 Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 9 de Nov. de 2023

0 votos

x_data = [1, 2, 3, 4, 5];
y_data = [6, 7, 8, 9, 10];
z_data = [11, 12, 13, 14, 15];
str = ["x" "y" "z"] + "data";
arr = table(x_data.', y_data.', z_data.', 'VariableNames', str);
filename = 'data.xlsx';
for k=1:size(arr,2)
writetable(arr(:,k), filename, 'Sheet', str(k))
end

2 comentarios

斗夢
斗夢 el 9 de Nov. de 2023
ありがとうございます!!
Dyuman Joshi
Dyuman Joshi el 9 de Nov. de 2023
You are welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2022b

Preguntada:

el 9 de Nov. de 2023

Comentada:

el 9 de Nov. de 2023

Community Treasure Hunt

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

Start Hunting!