Command prompt says: Not enough input arguments.

I want to define a function y and take it's partial derivatives wrt. b,c,d,e and display it's results by plugging in the values of x in it, which are taken as input.
please help me, I am new to Matlab.
but error says :
Not enough input arguments.
Error in pacejka_model_ansh (line 26)
y = f*d*sin(c*atan((b*x) - e*((b*x)) -atan(b*x)));
This is my code:
function [y] = pacejka_model_ansh(d,c,b,e)
m= input('number_of_data_set');
f= input('normal_force');
for i=1:m
fx(i,1)=input('initial_values_fx');
end
for i=1:m
fy(i,1)=input('initial_values_fy');
end
x=linspace (-10 ,0.5 , 10) ;
y = f*d*sin(c*atan((b*x) - e*((b*x)) -atan(b*x)));
y1(x)= diff(y,d);
y2(x)= diff(y,c);
y3(x)= diff(y,e);
y4(x)= diff(y,b);
f1 = zeros(n,1);
f2 = zeros(n,1);
f3 = zeros(n,1);
f4 = zeros(n,1);
for k=1:m
f1(k,1) = y1(fx(k,1));
end
for k=1:m
f2(k,1) = y2(fx(k,1));
end
for k=1:m
f3(k,1) = y3(fx(k,1));
end
for k=1:m
f4(k,1) = y4(fx(k,1));
end
disp (f1);
disp (f2);
disp (f3);
disp (f4);
end

5 Comments

You forgot to show us how you called it. For example, did you do
y = pacejka_model_ansh(2,pi,42,999);
? Or did you use some other numbers? What did you pass in for the arguments? One of them wasn't null was it?
Sir, I want to take the arguments d,c,b,e as variable. so that I can perform a partial differentiation of the function y = f*d*sin(c*atan((b*x) - e*((b*x)) -atan(b*x)));. with respect to d,c,b,e and hence display the result of these differentiations as a function of the other variables. for example. dy/dc= f(d,b,e,x).
You still didn't say how you called the function from the command line though. It looks like you simply didn't pass in the arguments.
Do I need to pass in the value of d,c,b,e as an integer Input ? I want to take them as variables and later find the values of those variables. The only input I want to pass in is in the form of data set (x,y), which I have already written as. I may be doing fundamental errors, please help me with this. I am quite new to coding.
m= input('number_of_data_set');
f= input('normal_force');
for i=1:m
fx(i,1)=input('initial_values_fx');
end
for i=1:m
fy(i,1)=input('initial_values_fy');
You use those variables in the line:
y = f*d*sin(c*atan((b*x) - e*((b*x)) -atan(b*x)));
They have to be defined before that. Whether that is from passing them to the function or creating them inside the function they must exist before they can be used.
Function syntax is relatively simple:
function [outputArg1, outputArg2,...] = funcName( inputArg1, inputArg2,...)
The input arguments are the ones you have to give it when you call it (unless you have optional arguments which can be left off), the output arguments you get back and assign to some variables.
If your code uses any of those input arguments then they must be passed in when you call the function. You can define a whole load of spurious input arguments that won't throw an error if your code never actually uses them, but it is pointless.

Sign in to comment.

Answers (0)

Asked:

on 19 Jun 2017

Commented:

on 29 Jun 2017

Community Treasure Hunt

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

Start Hunting!