How to solve startupFcn issue?
Show older comments
I have been trying to use the App Designer feature in Matlab. A portion of my code is below:
% Code that executes after component creation
function startupFcn(app, varargin)
% Configure image axes
app.ImageAxes.Visible = 'off';
app.ImageAxes.Colormap = gray(256);
axis(app.ImageAxes, 'image');
% Construct app
function app = Patient(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

Despite running the code multiple times, I get the above error message repeatedly. Any help would be appreciated. Thank you.
Answers (2)
So based on the code you shared it seems like you have made multiple copies of ImageAxes:
- ImageAxes
- ImageAxes_2
- ImageAxes_3
And in your public properties, just ImageAxes_2 and ImageAxes_3 are initialized. So somehow your original ImageAxes initialization was deleted. So now when your startup function is called it cannot find the ImageAxes property. I believe this happens when you rename a component in the App Designer multiple times, or create it multiple times.
So just add ImageAxes to your properties and you should be good to go!
The code:
classdef Patient < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
ImageAxes matlab.ui.control.UIAxes % Renamed this to ImageAxes
% all the other properties ...
end
% All the other functions and properties here ...
end
Warid Islam
on 11 Jun 2019
1 Comment
Rik
on 11 Jun 2019
This is not an answer. In future, please also post a link to your question if you choose to re-post something, and also include a link in your new question to the original for context.
And if you have much code (more than about 20 lines), please put it in an attachment to improve the readability of the thread.
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!