What command could run any file.m chosen
    2 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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.
0 件のコメント
採用された回答
  Jan
      
      
 2016 年 11 月 29 日
        What about considering the file path:
function start_Callback(hObject, eventdata, handles)
[FileName, FilePath] = uigetfile('*.m');
if ischar(FileName)  % Not aborted
  File = fullfile(FilePath, FileName);
  set(handles.edit1, 'String', File);
  run(File);
end
2 件のコメント
その他の回答 (1 件)
  Fangjun Jiang
      
      
 2016 年 11 月 29 日
        
      編集済み: Fangjun Jiang
      
      
 2016 年 11 月 29 日
  
      help run
FileName='c:\mydoc\test.m';
run(FileName);
6 件のコメント
  Guillaume
      
      
 2016 年 11 月 29 日
				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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


