필터 지우기
필터 지우기

save matrix to a file with filename specified by a string variable -- how to?

조회 수: 7 (최근 30일)
Pei JIA
Pei JIA 2011년 8월 15일
Hi, all:
I'm trying to save a bunch of matrix into a .mat file. 1) If I do save 'record.mat' mat_1 mat_2 mat_3 then, everything goes fine.
2) However, if I do fileName={'record.mat'} save {fileName} mat_1 mat_2 mat_3 then, nothing can be saved.
Since my program should run in recursively, so a bunch of files with different names should be produced. Therefore, I should be able to save file according to my own fileName specification. How to make 2) work?

답변 (1개)

Jan
Jan 2011년 8월 15일
fileName = 'record.mat';
save(fileName, 'mat_1', 'mat_2', 'mat_3');
This is explained explicitely in the help text: doc save. But such problems appear again and again.

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by