Error 'Not enough input arguments'

9 次查看(过去 30 天)
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

回答(1 个)

Steven Lord
Steven Lord 2016-12-1
You need to pass a value into the function, since the function is defined to accept an input argument u.
  2 个评论
Louis Saunders
Louis Saunders 2016-12-1
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 2016-12-1
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by