How to only have user select data file if workspace is empty?

2 Ansichten (letzte 30 Tage)
Kelsey
Kelsey am 22 Jul. 2014
Kommentiert: Kelsey am 23 Jul. 2014
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!

Akzeptierte Antwort

dpb
dpb am 22 Jul. 2014
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.

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by