How to only have user select data file if workspace is empty?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a generic code that calculates things based off of the data file that the user selects and loads into the Matlab Workspace. Here is my code to do that:
%%Load Data
% Open Matlab file (ATI data)
[a,b]=uigetfile('*.mat');
FileATI=fullfile(b,a);
dataATI = load(FileATI);
I know there is some intrinsic function like "if isempty" that would prevent me from having to select the file every single time I re-run my code. How would I do this? Thanks so much, in advance!
댓글 수: 0
채택된 답변
dpb
2014년 7월 22일
The term "generic" is iffy; but for the case as actually written/posted,
if ~exist('dataATI','var')
% load file stuff goes here
...
end
If any variables different in name are loaded then that's a problem, of course.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!