Error 'Not enough input arguments'

9 Ansichten (letzte 30 Tage)
Louis Saunders
Louis Saunders am 1 Dez. 2016
Bearbeitet: James Tursa am 1 Dez. 2016
Hi all, I am new to MATLAB software and I am having difficulty understanding this error code?
>> compacc
Error using compacc (line 8)
Not enough input arguments.
This is my data input:
function x=compacc(u)
% function to compute the slider acceleration
a = 72.36275; % a = AB = 72.36275
b = 182.61225; % b = BC = 182.61225
w_theta = u(1); % w_theta 1
dw_theta = u(2); % dw_theta 2
theta = u(3); % theta 3
alpha = u(4); % alpha 4
w_alpha = u(5); % w_alpha 5
A = [1.0 b*sin(alpha); 0.0 -b*cos(alpha)];
B = [-a*dw_theta*sin(theta) - a*w_theta*w_theta*cos(theta) - b*w_alpha*w_alpha*cos(alpha); ...
a*dw_theta*cos(theta) - a*w_theta*w_theta*sin(theta) - b*w_alpha*w_alpha*sin(alpha)];
x=inv(A)*B;
% x = [dV_d dw_alpha]
Many thanks

Antworten (1)

Steven Lord
Steven Lord am 1 Dez. 2016
You need to pass a value into the function, since the function is defined to accept an input argument u.
  2 Kommentare
Louis Saunders
Louis Saunders am 1 Dez. 2016
Thank you for the quick response, Apologies but I am still confused as to where exactly I input my value. Is this on Simulink or on the editor?
Steven Lord
Steven Lord am 1 Dez. 2016
Instead of calling it like this:
>> compacc
you would need to call it with an array that contains at least five elements, since your code accesses the fifth element of u when defining w_alpha.
w_alpha = u(5);
So try something like this:
>> compacc([1, 2, 3, 4, 5])
Note that I don't know the exact meaning of the variables to which you assign the elements of u in your code, so I just used a very simple vector to demonstrate.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by