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

조회 수: 25 (최근 30일)
斗夢
斗夢 2023년 11월 9일
댓글: Dyuman Joshi 2023년 11월 9일
x_data = [1, 2, 3, 4, 5];
y_data = [6, 7, 8, 9, 10];
z_data = [11, 12, 13, 14, 15];
このように3つのデータが得られたとき、その値のそれぞれをExcelのシート別に保存したい。
参考として下図のようなExcelファイルを保存したい。

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 9일
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
斗夢
斗夢 2023년 11월 9일
ありがとうございます!!
Dyuman Joshi
Dyuman Joshi 2023년 11월 9일
You are welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!