フィルターのクリア

Open an image when push button is clicked in app designer

21 ビュー (過去 30 日間)
Amit Patankar
Amit Patankar 2021 年 3 月 11 日
編集済み: Capx 2021 年 12 月 20 日
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 ?

採用された回答

Eli Chen
Eli Chen 2021 年 3 月 12 日
編集済み: Eli Chen 2021 年 3 月 12 日
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:
  1. Navigate to Component Browser, Select the push button in app tree, then define button clicking callback function name
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 件のコメント
Eli Chen
Eli Chen 2021 年 3 月 15 日
The error message says something is wrong at Line 202 in your app code, can you show me what code at Line 202?
Amit Patankar
Amit Patankar 2021 年 3 月 17 日
HI @Eli Chen, Adding these lines of code to the app introduces error in line 202, otherwise there is no error in the app. before adding the lines of code, model was running fine.

サインインしてコメントする。

その他の回答 (1 件)

Amit Patankar
Amit Patankar 2021 年 3 月 17 日
Hi @Eli Chen Please see thefollowing snapshot of code, The line where error lies comes in a non- editable part.
  9 件のコメント
Amit Patankar
Amit Patankar 2021 年 3 月 17 日
Unfortunately , As this work is confidential customer data, I wont be able to share app file.
As the error line mentiones, should I add UIAxes property in the app and some extra lines to the callback function ?
Capx
Capx 2021 年 12 月 20 日
編集済み: Capx 2021 年 12 月 20 日
@Eli Chen I've tried your code, and it works. I'm trying to do something similar; however, I would like the image displayed in two different image holders on the same window as the pushbutton rather than in a pop-up window.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by