Error 'Not enough input arguments'

8 ビュー (過去 30 日間)
Louis Saunders
Louis Saunders 2016 年 12 月 1 日
編集済み: James Tursa 2016 年 12 月 1 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by