Need help on MATLAB GUI button
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Monisha Nalluru
2020년 12월 8일
Hi Khang,
If you are using App Designer, I would suggest create properties within app which will store
- list of all image file names which you want to display in your app
- 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
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!