"Next Button" and "command window" in App Designer

조회 수: 4 (최근 30일)
WhiteFlower
WhiteFlower 2020년 4월 7일
댓글: Mohammad Sami 2021년 5월 20일
I am very new to Matlab App designer and have two questions. I appreciate any help.
  1. I have a series of images located in a folder. I would like to show them one at a time and then go to the next one by pressing the "Next" button. How can I program the "Next" button?
  2. I would like to see the values of variables in AppDesigner code. I know it's doable via debug mode and placing a break point at the line in which that variable is. But I don't see the values by hovering the mouse (although this feature is active in normal Matlab mode). Also, I don't really know where is the command window for App designer mode? I think it's not the same as Matlab command window because when I put variable's name there, it's undefined.
Thank you for any help
  댓글 수: 4
Vaishnavi
Vaishnavi 2021년 5월 19일
편집: Vaishnavi 2021년 5월 19일
I have recently started learning app designer.
I have similar question.
I want to design an app. I has 3 buttons load next and previous.
Load button will load 1st image from folder which contains many images and next and previous button will load next or previous image to image which is already in image component.
Mohammad Sami
Mohammad Sami 2021년 5월 20일
You can adapt the below code. Add a new function load previous as follows. You can then link it to your button callbacks.
function load_previous_image(app)
idx = app.currentidx - 1;
if idx == 0
idx = 1;
end
app.load_image_at_index(idx);
end

댓글을 달려면 로그인하십시오.

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 4월 7일
편집: Mohammad Sami 2020년 4월 7일
Make an app and add two properties. Filelist and currentidx and a placeholder for image in the app.
Make a function called load next image. Set it as the callback for your next button.
On startup load the filelist and display the first image.
properties (Access = private)
currentidx = 1; %set to 1 initially
Filelist = {};
end
function load_next_image(app)
idx = mod(app.currentidx + 1,length(app.Filelist));
if idx == 0
idx = 1;
end
app.load_image_at_index(idx);
end
function load_image_at_index(app,j)
app.currentidx = j;
impath = app.Filelist{j};
app.Image.ImageSource = impath;
end
% add a startup function by clicking AppInputArguments button in code view
function startupFcn(app,varargin)
% app.Filelist = {'C:\test\test.png'}; % assign your list
app.load_image_at_index(1);
end
  댓글 수: 8
Mohammad Sami
Mohammad Sami 2020년 4월 14일
uiimage component was added in R2019a
WhiteFlower
WhiteFlower 2020년 4월 14일
Thanks Mohammad!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by