Trying to learn how to display an image using app designer

9 Ansichten (letzte 30 Tage)
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
% 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];
methods (Access = public)
% Construct app
function app = app2test2
% Create and configure components
% 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
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
  2 Kommentare
Patrick Ford
Patrick Ford am 24 Okt. 2018
Right now I am attempting to learn how to use App design and want to access the variables in the work space that have been created by other apps to prototype. (Basically I am moving an .m to a have a gui)
I accomplished the effect by saving the image as a .mat file the reopening it.
X= open('JJ.mat');
imshow(X.JJ,'Parent', app.UIAxes);
where X is a stuct 1 with field JJ 128 x 128 double
But since I already have the data in ram, this is a lot of extra work and overhead.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chris Portal
Chris Portal am 25 Okt. 2018
You can pass workspace variables to your app using a startup function and app input arguments. The approach is described here:

Weitere Antworten (0)


Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by