Need help on MATLAB GUI button

Hello,
I am currently making a GUI that allow the user to click a button and a picture appear. Everytime the user clicks it, a new image will replace the old one. The problem is that I want to keep the old images while having the newer ones on the either the left ot right of the olds. Like a photo strip. This question is part of a major project I decided to work on, so any help is appreciated.

3 件のコメント

Deepak Gupta
Deepak Gupta 2020 年 12 月 3 日
Try appdesigner tool. It might help you.
Khang Nguyen
Khang Nguyen 2020 年 12 月 3 日
I already have an app going. I already understand how to implement images onto GUI using button. The problem is that I can't figure out how to keep the old image whenever I click the button. I searched up and couldn't find anything, so I hope that the community can help me or at least give me a lead.
Kartik Hegde
Kartik Hegde 2020 年 12 月 3 日
Try using multiple grids for old and new images

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

回答 (1 件)

Monisha Nalluru
Monisha Nalluru 2020 年 12 月 8 日

0 投票

Hi Khang,
If you are using App Designer, I would suggest create properties within app which will store
  1. list of all image file names which you want to display in your app
  2. a counter which track which image your are displaying currently
properties (Access = private) % can be public or private depending on use
imagecounter= 1;
imagelist=['newimage.png','newimg2.jpg'] % give list of all image you want to display
end
Documentation inorder to create properties in App Designer
Then write a callback function to button which will display the current image using imagecounter value and previous image using imagecounter-1. Handle case when imagecounter=1 since no previous image exists and results error
As an example
app.Image2.ImageSource=app.imagelist(app.imagecount); % Image2 is current image
app.Image1.ImageSource=app.imagelist(app.imagecount+1); % Image1 is previous image
Hope this helps!

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2020 年 12 月 3 日

回答済み:

2020 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by