What command could run any file.m chosen
Show older comments
Hi!
I create a GUI that allow me to browse files.m with the code below:
function start_Callback(hObject, eventdata, handles)
indir2 = uigetfile;
set(handles.edit1, 'String', indir2);
I get this result:

I want to run each time the selected file (regardless of the filename), but I still can not do it. How to proceed?
PS: I want to run the file via script.
Accepted Answer
More Answers (1)
Fangjun Jiang
on 29 Nov 2016
Edited: Fangjun Jiang
on 29 Nov 2016
help run
FileName='c:\mydoc\test.m';
run(FileName);
6 Comments
Samah EL QASSAH
on 29 Nov 2016
Jan
on 29 Nov 2016
"Does not work" is too lean to reconsider, what happens.
Guillaume
on 29 Nov 2016
"it does not work" is an extremely unhelpful statement.
In what way does it not work? Does it not produce the result you expect? In which case what does it do and what did you expect? does it produce an error? In which case what is the full error message?
Note that if the file you want to run is not on the matlab path, you have to give its full path to run, so:
[indir2, inpath2] = uigetfile;
run(fullfile(inpath2, indir2));
Samah EL QASSAH
on 29 Nov 2016
Edited: Samah EL QASSAH
on 29 Nov 2016
Guillaume
on 29 Nov 2016
Well, that would be because the code actually does not tell matlab to display the variables. Either remove the semicolons to tell matlab you want to display the result of the assignments, or use disp or fprintf.
Samah EL QASSAH
on 30 Nov 2016
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!