Clear Filters
Clear Filters

Unrecognized method, property, or field 'updateGraph' for class 'app1'.

9 views (last 30 days)
classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
YListBox matlab.ui.control.ListBox
YListBoxLabel matlab.ui.control.Label
XListBox matlab.ui.control.ListBox
XListBoxLabel matlab.ui.control.Label
LSpinner matlab.ui.control.Spinner
LSpinnerLabel matlab.ui.control.Label
VSBSpinner matlab.ui.control.Spinner
VSBSpinnerLabel matlab.ui.control.Label
VDSSpinner matlab.ui.control.Spinner
VDSSpinnerLabel matlab.ui.control.Label
VGSSpinner matlab.ui.control.Spinner
VGSSpinnerLabel matlab.ui.control.Label
pushButton matlab.ui.control.Button
lookupEditField matlab.ui.control.EditField
lookupEditFieldLabel matlab.ui.control.Label
nchEditField matlab.ui.control.EditField
nchEditFieldLabel matlab.ui.control.Label
importButton_3 matlab.ui.control.Button
importButton matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
end
% New property to store file path
properties (Access = public)
str = 'FilePath' % Store the selected file path
nch % Store the lookup table or other data
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: importButton
function importButtonPushed(app, event)
[app.nch,~]=uigetfile('*.mat','select mat file');
app.nchEditField.Value=app.nch;
figure(app.UIFigure);
end
% Value changed function: nchEditField
function nchEditFieldValueChanged(app, event)
value = app.nchEditField.Value;
end
% Button pushed function: importButton_3
function importButton_3Pushed(app, event)
[lookup,~]=uigetfile('*.m','select file');
lookupStr = char(lookup);
app.lookupEditField.Value=lookupStr;
figure(app.UIFigure);
end
% Value changed function: lookupEditField
function lookupEditFieldValueChanged(app, event)
value = app.lookupEditField.Value;
end
% Value changed function: LSpinner
function LSpinnerValueChanged(app, event)
selectedL = app.LSpinner.Value;
end
% Callback function: not associated with a component
function UIAxesButtonDown(app, event)
% Define gm_id values
gm_id = 0:0.1:50;
% Get ID_W values for the selected L
id_w = look_up(app.nch, 'ID_W', 'GM_ID', gm_id, 'L', selectedL);
% Plot ID_W against GM_ID on the UIAxes component
semilogx(app.UIAxes, (id_w)*10^6, gm_id, 'DisplayName', ['L = ', num2str(selectedL)]);
% Customize the plot
ylabel(app.UIAxes, 'g_m/I_D [S/A]');
xlabel(app.UIAxes, 'I_D/W [A/m]');
title(app.UIAxes, ['Plot for L = ', num2str(selectedL)]);
grid(app.UIAxes, 'on');
legend(app.UIAxes, 'Location', 'best');
function updateGraph(app, selectedLabel)
plot(app.UIAxes, rand(1,10)); % Example plot
title(app.UIAxes, selectedLabel);
xlabel(app.UIAxes, 'X-axis');
ylabel(app.UIAxes, 'Y-axis');
end
end
% Button pushed function: pushButton
function pushButtonPushed(app, event)
selectedLabel = app.XListBox.Value; % Assuming XListBox is used to select the label
% You can also add additional code here if needed
disp(['Graph updated for ', selectedLabel]);
end
% Value changed function: XListBox
function XListBoxValueChanged(app, event)
selectedLabel = app.XListBox.Value;
end
% Value changed function: YListBox
function YListBoxValueChanged(app, event)
selectedLabel = app.UIFigureapp.YListBox.Value;
app.updateGraph(selectedLabel);
app.UIFigure
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 640 480];
app.UIFigure.Name = 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [239 295 300 185];
% Create importButton
app.importButton = uibutton(app.UIFigure, 'push');
app.importButton.ButtonPushedFcn = createCallbackFcn(app, @importButtonPushed, true);
app.importButton.Position = [57 202 100 23];
app.importButton.Text = 'import';
% Create importButton_3
app.importButton_3 = uibutton(app.UIFigure, 'push');
app.importButton_3.ButtonPushedFcn = createCallbackFcn(app, @importButton_3Pushed, true);
app.importButton_3.Position = [43 273 100 23];
app.importButton_3.Text = 'import';
% Create nchEditFieldLabel
app.nchEditFieldLabel = uilabel(app.UIFigure);
app.nchEditFieldLabel.HorizontalAlignment = 'right';
app.nchEditFieldLabel.Position = [30 240 25 22];
app.nchEditFieldLabel.Text = 'nch';
% Create nchEditField
app.nchEditField = uieditfield(app.UIFigure, 'text');
app.nchEditField.ValueChangedFcn = createCallbackFcn(app, @nchEditFieldValueChanged, true);
app.nchEditField.Position = [70 240 100 22];
% Create lookupEditFieldLabel
app.lookupEditFieldLabel = uilabel(app.UIFigure);
app.lookupEditFieldLabel.HorizontalAlignment = 'right';
app.lookupEditFieldLabel.Position = [18 307 40 22];
app.lookupEditFieldLabel.Text = 'lookup';
% Create lookupEditField
app.lookupEditField = uieditfield(app.UIFigure, 'text');
app.lookupEditField.ValueChangedFcn = createCallbackFcn(app, @lookupEditFieldValueChanged, true);
app.lookupEditField.Position = [73 307 100 22];
% Create pushButton
app.pushButton = uibutton(app.UIFigure, 'push');
app.pushButton.ButtonPushedFcn = createCallbackFcn(app, @pushButtonPushed, true);
app.pushButton.Position = [350 265 100 23];
app.pushButton.Text = 'push';
% Create VGSSpinnerLabel
app.VGSSpinnerLabel = uilabel(app.UIFigure);
app.VGSSpinnerLabel.HorizontalAlignment = 'right';
app.VGSSpinnerLabel.Position = [46 447 30 22];
app.VGSSpinnerLabel.Text = 'VGS';
% Create VGSSpinner
app.VGSSpinner = uispinner(app.UIFigure);
app.VGSSpinner.Step = 0.05;
app.VGSSpinner.Limits = [0 1.8];
app.VGSSpinner.Position = [91 447 70 22];
% Create VDSSpinnerLabel
app.VDSSpinnerLabel = uilabel(app.UIFigure);
app.VDSSpinnerLabel.HorizontalAlignment = 'right';
app.VDSSpinnerLabel.Position = [49 417 30 22];
app.VDSSpinnerLabel.Text = 'VDS';
% Create VDSSpinner
app.VDSSpinner = uispinner(app.UIFigure);
app.VDSSpinner.Step = 0.05;
app.VDSSpinner.Limits = [0 1.8];
app.VDSSpinner.Position = [94 417 71 22];
% Create VSBSpinnerLabel
app.VSBSpinnerLabel = uilabel(app.UIFigure);
app.VSBSpinnerLabel.HorizontalAlignment = 'right';
app.VSBSpinnerLabel.Position = [49 386 29 22];
app.VSBSpinnerLabel.Text = 'VSB';
% Create VSBSpinner
app.VSBSpinner = uispinner(app.UIFigure);
app.VSBSpinner.Step = 0.1;
app.VSBSpinner.Limits = [0 0.7];
app.VSBSpinner.Position = [93 386 72 22];
% Create LSpinnerLabel
app.LSpinnerLabel = uilabel(app.UIFigure);
app.LSpinnerLabel.HorizontalAlignment = 'right';
app.LSpinnerLabel.Position = [51 353 25 22];
app.LSpinnerLabel.Text = 'L';
% Create LSpinner
app.LSpinner = uispinner(app.UIFigure);
app.LSpinner.Step = 0.02;
app.LSpinner.Limits = [0.24 0.48];
app.LSpinner.ValueChangedFcn = createCallbackFcn(app, @LSpinnerValueChanged, true);
app.LSpinner.Position = [91 353 70 22];
app.LSpinner.Value = 0.24;
% Create XListBoxLabel
app.XListBoxLabel = uilabel(app.UIFigure);
app.XListBoxLabel.HorizontalAlignment = 'right';
app.XListBoxLabel.Position = [239 230 25 22];
app.XListBoxLabel.Text = 'X ';
% Create XListBox
app.XListBox = uilistbox(app.UIFigure);
app.XListBox.Items = {'g_m/I_D', 'Item 2', 'Item 3', 'Item 4'};
app.XListBox.ValueChangedFcn = createCallbackFcn(app, @XListBoxValueChanged, true);
app.XListBox.Position = [279 231 100 21];
app.XListBox.Value = 'g_m/I_D';
% Create YListBoxLabel
app.YListBoxLabel = uilabel(app.UIFigure);
app.YListBoxLabel.HorizontalAlignment = 'right';
app.YListBoxLabel.Position = [399 230 25 22];
app.YListBoxLabel.Text = 'Y ';
% Create YListBox
app.YListBox = uilistbox(app.UIFigure);
app.YListBox.Items = {'I_D/W', 'Item 2', 'Item 3', 'Item 4'};
app.YListBox.ValueChangedFcn = createCallbackFcn(app, @YListBoxValueChanged, true);
app.YListBox.Position = [439 231 100 21];
app.YListBox.Value = 'I_D/W';
% 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 = app1
% Create UIFigure and components
createComponents(app)
% 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
I am beginner in matlab,recently I started building an application for gm/id methodology I tried to import look_up function and lookup tables which I generated,while building this GUI I am facing this error "Unrecognized method, property, or field 'updateGraph' for class 'app1'" for the above code, I am getting these below mentioned errors as well and not getting the plot also.
Error in app1/LSpinnerValueChanged (line 117)
app.updateGraph(selectedL);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Spinner PrivateValueChangedFcn.

Answers (1)

Steven Lord
Steven Lord on 4 Apr 2024
Your updateGraph function is nested inside your UIAxesButtonDown method. So it's not a method of the class.
Move the updateGraph function so it follows the end that ends the UIAxesButtonDown method. That will make it a method of the class.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!