- Navigate to Component Browser, Select the push button in app tree, then define button clicking callback function name
Open an image when push button is clicked in app designer
41 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HI !
I have a push button in the app. I want the push button to open an image file ( file name will be pre-defined in the code) .
I do not want to browse the image file.
What syntax should I use to get this worked ?
0 commentaires
Réponse acceptée
Eli Chen
le 12 Mar 2021
Modifié(e) : Eli Chen
le 12 Mar 2021
Hi,
Assume you have the target image file at your working directory, for example, MatlabLogo.png. And you have a push button in your app. These steps can help you opening the image by clicking on the push button:
2. Click the blue icon next to function name, you will be navigated to code view
3. Inside push button clicking callback function, you can use syntax like this:
% Button pushed function: Button
function showImage(app, event)
img = imread('MatlabLogo.png');
image(img);
end
When you run your app, and click this button, the image should be opened in Matlab Figure without browsing it
3 commentaires
Eli Chen
le 15 Mar 2021
The error message says something is wrong at Line 202 in your app code, can you show me what code at Line 202?
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!