running the user selected .m file in the pushbutton callback

4 vues (au cours des 30 derniers jours)
pammy le 3 Juil 2013
on push button number 1 i wrote the code to browse the . m file like this:
handles.output = hObject;
[fn pn] = uigetfile('*.m','select your file');
complete=[pn fn];
on push button 2 i.e running the selected file i wrote the code like this:
handles.output = hObject;
it does not produces any output...
if the select the file named count.m and in pushbutton 2 i simply wrtite count
then it'll execute and give me the results but when i want to generalize it like i said above, the output is not shown.. can u tell me whats is the problem in it....

Réponse acceptée

Guru le 3 Juil 2013
Modifié(e) : Guru le 3 Juil 2013
Umm, by what I am guessing you are trying to do in your push button 2 callback is that you want to run the file that was selected.
fn is a variable that contains a char array of the file name selected with the .m extension. Simply stating a variable in MATLAB would display this if you did not have the semicolon "fn;"
However to execute the file name in MATLAB you can use the "run" command
In short, the line of code that reads:
should be changed to:
  3 commentaires
Guru le 3 Juil 2013
Ahh yes. The solution I gave above assumes that the path location of the file is on the matlab path already. But yes, including the full path in your function call would run. You can also add the pn to the matlab path with
if that was intended.
Edit: changing original post to make use of the code markup text.

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur 2-D and 3-D Plots 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