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!