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

Risposte (1)

James Tursa
James Tursa il 9 Feb 2017
Modificato: James Tursa il 9 Feb 2017
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

Categorie

Scopri di più su Functions in Centro assistenza e File Exchange

Richiesto:

il 9 Feb 2017

Modificato:

il 9 Feb 2017

Community Treasure Hunt

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

Start Hunting!

Translated by