Hi All
I have written an app that using a pushbutton receives the working directory folder adress from the user and changes the matlab wd to that. the other push button is to run an mfile in thatdirectory and then cd() to some subfolder.
Despite I see the global variable shared between app and workspace ,it seems that matlab can not use it and therefore the cd() does not work cause the variable is seen as empty despite it's not
here is the app code :
properties (Access = public) %selectedPath: path selected by user in ButtonPushed function
selectedPath= 'C:\' % Description
end methods (Access = private) % Button pushed function: ChooseDirectoryButton
function ChooseDirectoryButtonPushed(app, event) global currentFolder app.selectedPath = uigetdir(); app.UIFigure.Visible = 'on'; currentFolder=app.selectedPath; cd(currentFolder) end % Button pushed function: ExecuteButton
function ExecuteButtonPushed(app, event) global currentFolder; currentFolder=app.selectedPath; assignin('base','currentFolder',currentFolder); goFolder = strcat(currentFolder,'\Fsolver.m'); run(goFolder) app.UIFigure.Visible = 'on'; end end
and the first lines of the mfile :
global currentFolderinputs =strcat(currentFolder,'\Input')cd(inputs)
these are the errors :
Error using cdCannot CD to \Input (Name is nonexistent or not a directory).Error in mysolver (line 37)cd(inputs)Error in run (line 91)evalin('caller', strcat(script, ';'));Error in apprivate/ExecuteButtonPushed (line 39) run(goFolder) Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 309)Error while evaluating Button PrivateButtonPushedFcn.
Best Answer