MATLAB: Open results file via standalone application

MATLAB: Open results file via standalone application

app designercompilerMATLAB Compilerwinopen

I created an application using appdesigner. The application reads certain inputs from an excel file, then makes some calculations, and then writes the results of those calculations in another excel file (let’s call it the “results” file). It also generates some plots and stores them as images (.jpg) in a folder of my choice. I have programmed a button in the app so that when I click it, I open the “results file” just created. I also programmed another button to open a windows folder (a folder in the windows environment) from which I see and open whatever plot I want (the ones saved as .jpg)
The app works as a charm, however, when I compile it to have a standalone version, I can’t open these files.
Now, if I make sure the files are included when I’m compiling the application, then I am able to open the files with the standalone version, however, I would not be opening the “fresh” result files recently created, instead, I always open whatever file was in the directory at the moment of compilation.
I use the function winopen to open both, the excel files and the folder in windows.
Something similar happened with the input excel file, but I managed to find a solution. I changed its name before compiling (from “input file” to “input file_1”). Then compiled it. Then changed the name back to “input file” which is what my scripts are going to look for.
So, how can I open an external file with a standalone app if the file is not hardcoded or compiled with the app??

Best Answer

  • Can you share the portion of your code that is opening the file / folder. The best option is to use full path to file and folder. You can construct the full path using the fullfile function. In a compiled application the function pwd will return either the folder containing the exe folder or the folder which contained the shortcut to the exe.
  • Add a Comment

    Your email address will not be published. Required fields are marked *