Is there a load if statement or similar in matlab, way to save workspace variable's seperate mat files?
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to only load a mat file if it isn't loaded. Is there a way to tell if it is loaded?
Is there a way to store every workspace variable as its own mat file by chance?
댓글 수: 0
채택된 답변
Jan
2012년 3월 13일
This creates a list of currently defined variables:
List = who;
Then omit ans:
List(strcmp(List, 'ans')) = [];
And save the others:
for k = 1:length(List)
save(List{k});
end
Then this bunch of files can be loaded without overwriting existing variables:
matList = dir('*.mat');
List = who;
for k = 1:length(matList)
name = matList(k).name;
if ~any(strcmp(name, List))
load(name);
end
end
But I would avoid this consequently: 1. load without catching the input to a variable is prone to errors. 2. The debugging of your program will be impeded by this method, because it conceals the source of the values.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!