Error 'Not enough input arguments'

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일

0 개 추천

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?
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2016년 12월 1일

편집:

2016년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by