Trying to learn how to display an image using app designer
조회 수: 23 (최근 30일)
이전 댓글 표시
My goal is to display a series of cine images for QA that obviously displays the cine, and adjust the speed, intensity, etc. I am trying to use app designer to do this, which is probably trivial, but I am running into conceptual issues on my part. I have an image JJ created using the following in the Command Window:
JJ = imagesc(imadjust(dtx(:,:,1))); % where dtx is the cine data in the Workspace and JJ.CData is 128x128 double
Now these variable are in the Workspace and I can share then with other .m programs I have loaded, but when I copy over the mlapp text, edit it and run it, it does not see the current Workspace variables.
So how do I share the Workspace variables? Also I cannot edit the script while in Code View. Why is that the case and how do I modify that?
Text that I am trying to display a single image frame.
________________________________________________________________
classdef app2test2 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
end
% App initialization and construction
methods (Access = public)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title')
app.UIAxes.XColor = [1 1 1];
app.UIAxes.XTick = [];
app.UIAxes.YColor = [1 1 1];
app.UIAxes.YTick = [];
app.UIAxes.Position = [72 69 420 310];
end
end
methods (Access = public)
% Construct app
function app = app2test2
% Create and configure components
createComponents(app)
% JJ = imagesc(imadjust(dtx(:,:,1)));
imshow(JJ.CData,'Parent', app.UIAxes);
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
댓글 수: 2
Adam
2018년 10월 24일
If I remember correctly, the constructor of App Designer classes now take arguments (they didn't until a very recent version of Matlab) so you can just pass them in there, or put them in a struct or, even better, their own parameter class(es), to pass in if there are a few of them.
채택된 답변
Chris Portal
2018년 10월 25일
You can pass workspace variables to your app using a startup function and app input arguments. The approach is described here:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!