Hello, so, I want to pass a variable from one GUI to another GUI after I use a PushButton. I have attached a code:
classdef GUI < matlab.apps.AppBase % Properties that correspond to app components
properties (Access = public) UIFigure matlab.ui.Figure BlindDeconvolutionPanel matlab.ui.container.Panel UIAxes matlab.ui.control.UIAxes UploadButton matlab.ui.control.Button DeconvoluteButton matlab.ui.control.Button ParametersPanel matlab.ui.container.Panel GaussianVarianceEditFieldLabel matlab.ui.control.Label GaussianVarianceEditField matlab.ui.control.NumericEditField IterationsEditFieldLabel matlab.ui.control.Label IterationsEditField matlab.ui.control.NumericEditField end properties (Access = public) image % Description
end % Callbacks that handle component events
methods (Access = private) % Code that executes after component creation
function startupFcn(app) end % Button pushed function: UploadButton
function UploadButtonPushed2(app, event) [file1,path] = uigetfile({'*.png';'*.jpg';'*.tiff';'*.jpeg'},... 'File Selector'); file=fullfile(path,file1) a=imread(file) app.image=imcrop(a,[145 58 370 370]) imshow(app.image,'Parent',app.UIAxes) title(sprintf('%s',file1),'Parent',app.UIAxes) end % Button pushed function: DeconvoluteButton
function DeconvoluteButtonPushed(app, event)
GUI2 % here is the problem
% PSF = fspecial('gaussian',[371 371],app.GaussianVarianceEditField.Value)
% [J,psfr]=deconvblind(app.image,PSF,app.IterationsEditField.Value)
% % psfr=fft(psfr)
% figure
% %J=J./max(max(J))
% subplot(224)
% imagesc(J)
% title('Output Image')
% colorbar
% subplot(223)
% imagesc(psfr./max(max(psfr)))
% title('Extracted PSF')
% colorbar% subplot(221)
% imagesc(PSF./max(max(PSF)))
% title('Original PSF')
% colorbar% subplot(222)
% imagesc(app.image)
% title('Original ')
% colorbar 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 548 309]; app.UIFigure.Name = 'UI Figure'; % Create BlindDeconvolutionPanel
app.BlindDeconvolutionPanel = uipanel(app.UIFigure); app.BlindDeconvolutionPanel.TitlePosition = 'centertop'; app.BlindDeconvolutionPanel.Title = 'Blind Deconvolution'; app.BlindDeconvolutionPanel.FontWeight = 'bold'; app.BlindDeconvolutionPanel.Position = [0 2 549 308]; % Create UIAxes
app.UIAxes = uiaxes(app.BlindDeconvolutionPanel); title(app.UIAxes, '') xlabel(app.UIAxes, '') ylabel(app.UIAxes, '') app.UIAxes.XColor = 'none'; app.UIAxes.XTick = []; app.UIAxes.YColor = 'none'; app.UIAxes.YTick = []; app.UIAxes.ZColor = 'none'; app.UIAxes.ZTick = []; app.UIAxes.Position = [1 43 280 234]; % Create UploadButton
app.UploadButton = uibutton(app.BlindDeconvolutionPanel, 'push'); app.UploadButton.ButtonPushedFcn = createCallbackFcn(app, @UploadButtonPushed2, true); app.UploadButton.Position = [362 246 100 22]; app.UploadButton.Text = 'Upload'; % Create DeconvoluteButton
app.DeconvoluteButton = uibutton(app.BlindDeconvolutionPanel, 'push'); app.DeconvoluteButton.ButtonPushedFcn = createCallbackFcn(app, @DeconvoluteButtonPushed, true); app.DeconvoluteButton.Position = [363 188 100 22]; app.DeconvoluteButton.Text = 'Deconvolute'; % Create ParametersPanel
app.ParametersPanel = uipanel(app.BlindDeconvolutionPanel); app.ParametersPanel.TitlePosition = 'centertop'; app.ParametersPanel.Title = 'Parameters'; app.ParametersPanel.FontWeight = 'bold'; app.ParametersPanel.Position = [295 19 237 136]; % Create GaussianVarianceEditFieldLabel
app.GaussianVarianceEditFieldLabel = uilabel(app.ParametersPanel); app.GaussianVarianceEditFieldLabel.HorizontalAlignment = 'right'; app.GaussianVarianceEditFieldLabel.Position = [9 78 106 22]; app.GaussianVarianceEditFieldLabel.Text = 'Gaussian Variance'; % Create GaussianVarianceEditField
app.GaussianVarianceEditField = uieditfield(app.ParametersPanel, 'numeric'); app.GaussianVarianceEditField.Tooltip = {'enter a number possibly 20 or higher'}; app.GaussianVarianceEditField.Position = [130 78 100 22]; % Create IterationsEditFieldLabel
app.IterationsEditFieldLabel = uilabel(app.ParametersPanel); app.IterationsEditFieldLabel.HorizontalAlignment = 'right'; app.IterationsEditFieldLabel.Position = [46 24 55 22]; app.IterationsEditFieldLabel.Text = 'Iterations'; % Create IterationsEditField
app.IterationsEditField = uieditfield(app.ParametersPanel, 'numeric'); app.IterationsEditField.Tooltip = {'Keep Iterations low 2 works best '}; app.IterationsEditField.Position = [131 24 100 22]; % 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 = GUI % Create UIFigure and components createComponents(app) % Register the app with App Designer
registerApp(app, app.UIFigure) % Execute the startup function
runStartupFcn(app, @startupFcn) 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 endend
After I press the DeconvoluteButtonPushed2 I want the new GUI to come up and all the variables in this GUI should be passed to the new GUI. Please suggest me something, thanks!
Best Answer