App designer - trouble with the example code

11 views (last 30 days)
Pete on 29 Aug 2016
Commented: Pete on 30 Aug 2016
Hi everyone
I'm brand new to app designer.
I've tried creating the first three apps in the help documentation:
I can't get any of them to work. I get the same error message in each: "Error using plot. Too many input arguments"
I notice that in the command window I get a warning: "Warning: Function plot has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict."
My code is exactly the same as in the help documentation - I haven't created a function called plot.
Baffled - can anyone help?
classdef simplePlot < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure % UI Figure
UIAxes matlab.ui.control.UIAxes % Title
LabelNumericEditField matlab.ui.control.Label % Enter value
NumericEditField matlab.ui.control.NumericEditField % [-Inf Inf]
Button matlab.ui.control.Button % Plot
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
% Button button pushed function
function ButtonButtonPushed(app)
x = 0:pi/100:2*app.NumericEditField.Value;
y = sin(2*x);
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 899 697];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title');
xlabel(app.UIAxes, 'X');
ylabel(app.UIAxes, 'Y');
app.UIAxes.Position = [38 132 462 499];
% Create LabelNumericEditField
app.LabelNumericEditField = uilabel(app.UIFigure);
app.LabelNumericEditField.HorizontalAlignment = 'right';
app.LabelNumericEditField.Position = [613 470 60 15];
app.LabelNumericEditField.Text = 'Enter value';
% Create NumericEditField
app.NumericEditField = uieditfield(app.UIFigure, 'numeric');
app.NumericEditField.Position = [688 466 100 22];
% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonButtonPushed);
app.Button.Position = [688 359 100 22];
app.Button.Text = 'Plot';
methods (Access = public)
% Construct app
function app = simplePlot()
% Create and configure components
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
Thanks in advance.
Pete on 30 Aug 2016
There was a plot function hiding in amongst all my messy test files - very careless. Thanks for your help.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by