Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Not enough input arguments

조회 수: 1 (최근 30일)
Anna
Anna 2013년 7월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
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.

답변 (2개)

per isakson
per isakson 2013년 7월 27일
편집: per isakson 2013년 7월 27일
Try
>> seven_raised_to_two = my_Square( 7 );
where
function y = my_Square(x)
y = x^2;
end
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

Jan
Jan 2013년 7월 27일
Your function looks correct. I assume, you called it without an input argument:
Square
instead of providing the input:
Square(7)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by