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!

采纳的回答

dpb
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 CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by