Info

此问题已关闭。 请重新打开它进行编辑或回答。

too many output argumentws

1 次查看(过去 30 天)
ajinkya bhoi
ajinkya bhoi 2020-6-7
关闭: MATLAB Answer Bot 2021-8-20
Hello,
I am getting too many input and output arguments error, I have tried to solve it but i am not able to understand the way to solve.
below is my fucntion
function [x_t,v_t] = Exercise_2_1_solve_equation_of_motion_analytically_func (mass,stiffness,damping,time,x_0,x_dot_0)
%% 2.) Computing
%% 2.) -Parameter calculation
dampingcoefficient = damping/2*mass; % Calculate damping coefficient
angulareigenfrequency = sqrt(stiffness/mass); % Calculate angular eigenfrequency
%% 2.) -Calculation of the characteristic polynomial
lambda = roots([1,2*dampingcoefficient,angulareigenfrequency^2]); %Calculate roots
%% 2.) -Calculation of the constants
k1 = (x_dot_0-lambda(2)*x_0)/(lambda(1)-lambda(2)); % Calculation of the constant 1
k2 = (lambda(1)*x_0-x_dot_0)/(lambda(1)-lambda(2)); % Calculation of the constant 2
%% 2.) -Calculation of the solution
x_t_h = k1*exp(lambda(1)*time)+k2*exp(lambda(2)*time);
v_t_h = k1*lambda(1)*exp(lambda(1)*time)+k2*lambda(2)*exp(lambda(2)*time);
x_t = real(x_t_h); % Make sure only real part is considered
v_t = real(v_t_h); % Make sure only real part is considered
end
And the calling script is as below :
%%To solve equation of motion analytically
%% Parameter definition
mass = 750; % Mass of the body [kg]
stiffness = 50000; % Stiffness Coefficient of spring [N/m]
damping = 1000; % Damping coefficient of damper [Ns/m]
time = 0:0.01:1; % Time [s]
x_0 = 0.01; % Initial Condition displacement
x_dot_0 = 0; % Initial Condition velocity
%% Call the function
[x_t,v_t] = Exercise_2_1_solve_equation_of_motion_analytically_func(mass,stiffness,damping,time,x_0,x_dot_0);
  1 个评论
KSSV
KSSV 2020-6-7
It is running fine....the number of inputs and outputs are correct. Are you giving the function name correct?

回答(1 个)

Vishal Gaur
Vishal Gaur 2020-6-8
Your Code is correct. Check if you have misspelled any argument name or the function name.

此问题已关闭。

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by