Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

too many output argumentws

1 Ansicht (letzte 30 Tage)
ajinkya bhoi
ajinkya bhoi am 7 Jun. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentar
KSSV
KSSV am 7 Jun. 2020
It is running fine....the number of inputs and outputs are correct. Are you giving the function name correct?

Antworten (1)

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

Diese Frage ist geschlossen.

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by