MATLAB Answers


Not enough input arguments

Asked by Anna
on 27 Jul 2013

Hi all,

I am very new to matlab and programming in general. I am having difficulty with functions.

Trying to grip the basics i entered this which I saw online:

function [y] = Square(x) y = x^2 return

I get the error message "Not enough input arguments" If anyone can tell me in basic terms what is going on that would be much appreciated.



No products are associated with this question.

2 Answers

Answer by per isakson
on 27 Jul 2013
Edited by per isakson
on 27 Jul 2013


    >> seven_raised_to_two = my_Square( 7 );


    function  y = my_Square(x) 
       y = x^2; 

are three lines in a separate file named my_Square.m

Neither [y] nor return is wrong, but ...


To be sure not to cause a name conflict my_Square is better, sice there is a function named square in the signal-something-toolbox.

    >> which square
    C:\Program Files\MATLAB\R2013a\toolbox\signal\signal\square.m


Answer by Jan Simon
on 27 Jul 2013

Your function looks correct. I assume, you called it without an input argument:


instead of providing the input:



Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!