Why does my code say too many input arguments?

function [ rts, info ] = cubicxxxx( C )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
%C = [1 3 4 5]%example of vector
x0=1;
f=@ (x) C(1,1)*x.^3+C(1,2)*x.^2+C(1,3)*x+C(1,4);% cubic function
g=@ (x) C(1,1)*3*x.^2+C(1,2)*2*x+C(1,3);% derivative of cubic function
f(x0);
g(x0);
b=f(x0)-0;
while b<10^-6
y =x0-((f(x0))/(g(x0)));
x0=y;
b=f(x0)-0;
end
display(x0)
end

답변 (1개)

James Tursa
James Tursa 2017년 2월 9일
편집: James Tursa 2017년 2월 9일

0 개 추천

How are you calling this function? E.g.,
>> cubicxxxx(1:4) % <-- one input vector
x0 =
1
>> cubicxxxx(2:5) % <-- one input vector
x0 =
1
>> cubicxxxx(2:5,8) % <-- two inputs
??? Error using ==> cubicxxxx
Too many input arguments.
>> cubicxxxx(1,2,3,4) % <-- four inputs
??? Error using ==> cubicxxxx
Too many input arguments.
>> cubicxxxx([1,2,3,4]) % <-- one input vector
x0 =
1

카테고리

도움말 센터File Exchange에서 Functions에 대해 자세히 알아보기

질문:

2017년 2월 9일

편집:

2017년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by