App designer - trouble with the example code
3 views (last 30 days)
Show older comments
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
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
end
% Button button pushed function
function ButtonButtonPushed(app)
x = 0:pi/100:2*app.NumericEditField.Value;
y = sin(2*x);
plot(app.UIAxes,x,y)
end
end
% 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';
end
end
methods (Access = public)
% Construct app
function app = simplePlot()
% Create and configure 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
end
end
Thanks in advance.
2 Comments
Chris Portal
on 30 Aug 2016
Try the following and see if it returns any PLOT functions that look suspect:
which plot -all
Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer 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!