Calling/Running a .m File via Another Function

6 vues (au cours des 30 derniers jours)
Dan
Dan le 16 Déc 2011
Hi,
I'm trying to build an interface such that a user can select from different .m files to run. If you look at the code below, you can see that my idea is to allow a user to select a .m file from his/her directory and then run it. I've tried various modifications to the code below, but nothing seems to work. The error that I get is "tempRunGui is not found"
function runGUI1Callback(src, eventdata)
tempRunGui = uigetfile('*.m', 'Select Run File');
run tempRunGui;
end
Any input/help is really appreciated.
Thanks!

Réponse acceptée

Jan
Jan le 16 Déc 2011
run is defined for scripts, not for functions. Are you talking of scripts?
You forgot the path of the file.
[FileName, PathName] = uigetfile('*.m', 'Select Run File');
if ~ischar(FileName) % Give the user a chance to cancel
return;
end
% If you are really talking about scripts:
run(fullfile(PathName, FileName));
  1 commentaire
Dan
Dan le 16 Déc 2011
That's the problem and that's the solution --- Thank You!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by