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

2 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

dpb
dpb il 22 Lug 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.

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by