Borrar filtros
Borrar filtros

StartupFcn to initiate the plot

3 visualizaciones (últimos 30 días)
royed
royed el 15 de Feb. de 2020
Respondida: Abhinav el 5 de Jul. de 2023
Hello,
This code must start after I press a button in the first GUI, which will result in this code to run with the startupFcn in the second GUI to plot this data:
classdef Deconvolution2 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
UIAxes_3 matlab.ui.control.UIAxes
ShowButton matlab.ui.control.Button
LineProfileButton matlab.ui.control.Button
end
properties (Access = public)
Data;
Data1;
Data2;
Lineprofile1;
Lineprofile2;
Lineprofilex;
end
properties (Access = private)
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app, Deconvolution, var1, var2, var3)
app.CallingApp = Deconvolution;
var1=imagesc(app.Data,'Parent',app.UIAxes,...
'XData', [1 app.UIAxes.Position(3)], ...
'YData', [1 app.UIAxes.Position(4)]);
app.UIAxes.XLim = [0 var1.XData(2)];
app.UIAxes.YLim = [0 var1.YData(2)];
%title(sprintf('%s',file1),'Parent',app.UIAxes)
var2=imagesc(app.Data1,'Parent',app.UIAxes_2,...
'XData', [1 app.UIAxes_2.Position(3)], ...
'YData', [1 app.UIAxes_2.Position(4)]);
app.UIAxes_2.XLim = [0 var2.XData(2)];
app.UIAxes_2.YLim = [0 var2.YData(2)];
%title(sprintf('%s',file1),'Parent',app.UIAxes)
var3=imagesc(app.Data2,'Parent',app.UIAxes_3,...
'XData', [1 app.UIAxes_3.Position(3)], ...
'YData', [1 app.UIAxes_3.Position(4)]);
app.UIAxes_3.XLim = [0 var3.XData(2)];
app.UIAxes_3.YLim = [0 var3.YData(2)];
%title(sprintf('%s',file1),'Parent',app.UIAxes)
end
% Button pushed function: ShowButton
function ShowButtonPushed(app, event)
% var1=imagesc(app.Data,'Parent',app.UIAxes,...
% 'XData', [1 app.UIAxes.Position(3)], ...
% 'YData', [1 app.UIAxes.Position(4)]);
% app.UIAxes.XLim = [0 var1.XData(2)];
% app.UIAxes.YLim = [0 var1.YData(2)];
% %title(sprintf('%s',file1),'Parent',app.UIAxes)
%
% var2=imagesc(app.Data1,'Parent',app.UIAxes_2,...
% 'XData', [1 app.UIAxes_2.Position(3)], ...
% 'YData', [1 app.UIAxes_2.Position(4)]);
% app.UIAxes_2.XLim = [0 var2.XData(2)];
% app.UIAxes_2.YLim = [0 var2.YData(2)];
% %title(sprintf('%s',file1),'Parent',app.UIAxes)
%
% var3=imagesc(app.Data2,'Parent',app.UIAxes_3,...
% 'XData', [1 app.UIAxes_3.Position(3)], ...
% 'YData', [1 app.UIAxes_3.Position(4)]);
% app.UIAxes_3.XLim = [0 var3.XData(2)];
% app.UIAxes_3.YLim = [0 var3.YData(2)];
% %title(sprintf('%s',file1),'Parent',app.UIAxes)
end
% Button pushed function: LineProfileButton
function LineProfileButtonPushed(app, event)
image=app.Data
figure
imagesc(image)
[cx,cy,c,xi,yi]=improfile
[cx,cy,c,xi,yi]=improfile(app.Data,xi,yi)
x=(1:size(c));
app.Lineprofilex=x
app.Lineprofile1=c
[cx,cy,c,xi,yi]=improfile(app.Data2,xi,yi)
app.Lineprofile2=c
Deconvolution3(app)
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 1125 370];
app.UIFigure.Name = 'UI Figure';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, '')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
app.UIAxes.GridColor = 'none';
app.UIAxes.MinorGridColor = 'none';
app.UIAxes.XColor = 'none';
app.UIAxes.XTick = [];
app.UIAxes.YColor = 'none';
app.UIAxes.YTick = [];
app.UIAxes.ZColor = 'none';
app.UIAxes.Clipping = 'off';
app.UIAxes.Position = [19 29 313 286];
% Create UIAxes_2
app.UIAxes_2 = uiaxes(app.UIFigure);
title(app.UIAxes_2, '')
xlabel(app.UIAxes_2, 'X')
ylabel(app.UIAxes_2, 'Y')
app.UIAxes_2.GridColor = 'none';
app.UIAxes_2.MinorGridColor = 'none';
app.UIAxes_2.XColor = 'none';
app.UIAxes_2.XTick = [];
app.UIAxes_2.YColor = 'none';
app.UIAxes_2.YTick = [];
app.UIAxes_2.ZColor = 'none';
app.UIAxes_2.Clipping = 'off';
app.UIAxes_2.Position = [407 29 313 286];
% Create UIAxes_3
app.UIAxes_3 = uiaxes(app.UIFigure);
title(app.UIAxes_3, '')
xlabel(app.UIAxes_3, 'X')
ylabel(app.UIAxes_3, 'Y')
app.UIAxes_3.GridColor = 'none';
app.UIAxes_3.MinorGridColor = 'none';
app.UIAxes_3.XColor = 'none';
app.UIAxes_3.XTick = [];
app.UIAxes_3.YColor = 'none';
app.UIAxes_3.YTick = [];
app.UIAxes_3.ZColor = 'none';
app.UIAxes_3.Clipping = 'off';
app.UIAxes_3.Position = [794 29 313 286];
% Create ShowButton
app.ShowButton = uibutton(app.UIFigure, 'push');
app.ShowButton.ButtonPushedFcn = createCallbackFcn(app, @ShowButtonPushed, true);
app.ShowButton.Position = [407 329 100 22];
app.ShowButton.Text = 'Show';
% Create LineProfileButton
app.LineProfileButton = uibutton(app.UIFigure, 'push');
app.LineProfileButton.ButtonPushedFcn = createCallbackFcn(app, @LineProfileButtonPushed, true);
app.LineProfileButton.Position = [561 329 100 22];
app.LineProfileButton.Text = 'Line Profile';
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = Deconvolution2(varargin)
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @(app)startupFcn(app, varargin{:}))
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
But after I am getting an error that states less input arguments in the startupFcn. Please help me out with it.

Respuestas (1)

Abhinav
Abhinav el 5 de Jul. de 2023
The problem is not in the above shared file.
But due to an error during the call, I would suggest to run the debugger on the previous GUI. Link to Documentation.
If that works fine, I'd ask you to next check how the data is being passed from one GUI to the next. Link to Documentation for sharing data between different apps.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by