MATLAB: GUI pwd behavior after deployment

guiMATLAB Compilerpath

It looks for me GUI remembers current work folder of development machine at compile time.
Is there a way to disable or walkaround this?
On the target deployed machine (only MCR installed), uigetfile() always starts from the pwd folder of the compiling machine (as long as it exists) otherwise then start from .\
And write file commands if path not specified always goes to the folder.
Printing pwd results give pwd of compiling machine (if exists), otherwise local.
Is it a designed behavior?
Please comment,

Best Answer

I do not believe what you said is true. I compile lots of apps all the time and don't observe that. The current folder of the deployed app is neither the current folder of your compiling machine, nor the folder where your deployed app is installed. Your deployed app is actually not the real executable but a self unarchiving file that unpacks the real executable to some strange folder in some bizarre location that you wouldn't expect. Perhaps Kaustubha will explain in more detail - I get tired of explaining this all the time.
What's probably happening in your case is that you have a call to cd() either in your app, or in your startup.m file. Your startup.m file on your development machine gets run when you run the deployed app on the target machine. If you want, you can check the isdeployed flag in your app and set the current folder to the place you want it to be depending on whether it's on the deployed or development machine.