- Check that the function 'printopt' is available on your MATLAB path. You can do this by typing 'which printopt' in the MATLAB command window. If the function is not found, you may need to add it to your path.
- Check that the syntax for the 'exportapp' command is correct. Make sure that you are passing the correct arguments and that the file path is valid.
- Try using the 'print' function instead of 'exportapp'. The 'print' function can be used to save a figure to a file. For example, you could use the following command to save the GUI figure as a JPEG image: print(app.MYAPPNAMEUIFigure, 'F:\GUI_PLOT.jpg', '-djpeg')
Exportapp causing undefined function "printopt" error
3 views (last 30 days)
Show older comments
Hello,
I developed an appplication (with App Designer) that reads real-time data from an instrument and creates a plot.
It worked OK until I added to the code the following command to save a copy of the GUI every 5 minutes:
exportapp(app.MYAPPNAMEUIFigure,'F:\GUI_PLOT.jpg')
every now and then I got the following error message:
undefined function "printopt" for input argument type matlab.ui.Root
I cannot understand what is wrong since the application works for most of the time.
By the way, is there a way to automatically dismiss such error dialogs? I created a Task (in windows Task Scheduler) that re-launch the application if it stops for some reasons, but the error dialog box interfere with it.
Any hints? Thanks!
0 Comments
Answers (1)
Aishwarya Shukla
on 1 Mar 2023
Hi @StefanoM64,
The error message "undefined function 'printopt' for input argument type matlab.ui.Root" suggests that there is a problem with the print options for your GUI figure. It seems like the function 'printopt' is not defined or available for the 'matlab.ui.Root' type.
To solve the problem, you could try the following:
Regarding the error dialog box, you could try using the 'try...catch' statement to handle the error and prevent the dialog box from being displayed. For example:
try
exportapp(app.MYAPPNAMEUIFigure, 'F:\GUI_PLOT.jpg')
catch
% Handle the error here end
This will try to execute the 'exportapp' command, and if an error occurs, the code inside the 'catch' block will be executed instead. You can use this block to handle the error in a way that suits your application, such as logging the error or displaying a custom error message.
3 Comments
Aishwarya Shukla
on 1 Mar 2023
It is possible that the error is caused by a conflict between the 'exportapp' function and other functions or processes running in your application.
One possibility is that the 'exportapp' function is being called at a time when the GUI figure is not fully loaded or initialized, causing the error to occur. To avoid this, you could try adding a short delay before calling the 'exportapp' function, to allow the GUI figure to fully initialize. For example:
pause(0.1); % add a 100 millisecond delay
exportapp(app.MYAPPNAMEUIFigure, 'F:\GUI_PLOT.jpg');
Another possibility is that the 'exportapp' function is causing a memory or resource conflict with other parts of your application. You could try monitoring your system resources (such as CPU and memory usage) during the operation of your application, to see if any resource constraints are being exceeded when the error occurs.
See Also
Categories
Find more on Interactive Control and Callbacks 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!