Error - not enough input arguments

조회 수: 6 (최근 30일)
Khubaib
Khubaib 2012년 9월 30일
Hello,
I wrote a function x3.m as follows:
function [ y ] = x3( x )
y=abs(x).^3;
end
Now I want to find the minimum of this function using fminunc.m with the initial value of 2. So I type this in the command window:
a=fminunc(x3,2)
But it returns the following error:
Error using x3 (line 4) Not enough input arguments.
Can anyone please tell me what the problem is with my code? Any help would be greatly appreciated.
Thanks, Khubaib

채택된 답변

Wayne King
Wayne King 2012년 9월 30일
x3 should be entered as a function handle.
a=fminunc(@x3,2)
Or in this case:
a = fminunc(@(x) abs(x)^3,2);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Automated Driving Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by