# value assigned to variable might be unsured (Ln 12)

1 vue (au cours des 30 derniers jours)
firas le 11 Mai 2023
Réponse apportée : Shaik le 11 Mai 2023
m = 45; % mass in kg
k = 35000; % spring constant in N/m
c = 1200; % damping coefficient in N*s/m
F0 = 600; % amplitude of the force in N
omega = 40; % angular frequency of the force in rad/s
x0 = 0.0001; % initial displacement in m
v0 = 0.1; % initial velocity in m/s
t = linspace(0, 10, 1000); % time range from 0 to 10 seconds with 1000 data points
% Calculate the response function using the equation of motion:
omega_n = sqrt(k / m); % natural frequency
zeta = c / (2 * sqrt(m * k)); % damping ratio
omega_d = omega_n * sqrt(1 - zeta^2); % damped natural frequency
% Calculate the response function using the equation of motion:
omega_n = sqrt(k / m); % natural frequency
zeta = c / (2 * sqrt(m * k)); % damping ratio
omega_d = omega_n * sqrt(1 - zeta^2); % damped natural frequency
figure;
plot(t, X);
Unrecognized function or variable 'X'.
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Response of Mass-Spring-Damper System');
grid on;
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Shaik le 11 Mai 2023
Hi Firas,
I hope this resolves your issue,
m = 45; % mass in kg
k = 35000; % spring constant in N/m
c = 1200; % damping coefficient in N*s/m
F0 = 600; % amplitude of the force in N
omega = 40; % angular frequency of the force in rad/s
x0 = 0.0001; % initial displacement in m
v0 = 0.1; % initial velocity in m/s
t = linspace(0, 10, 1000); % time range from 0 to 10 seconds with 1000 data points
% Calculate the response function using the equation of motion:
omega_n = sqrt(k / m); % natural frequency
zeta = c / (2 * sqrt(m * k)); % damping ratio
omega_d = omega_n * sqrt(1 - zeta^2); % damped natural frequency
X = (F0/m) ./ ((omega_n^2 - omega^2 + 2i*zeta*omega_n*omega) .* (omega_n^2 - omega^2 - 2i*zeta*omega_n*omega)); % displacement response
figure;
plot(t, real(X)*cos(omega_d*t) - imag(X)*sin(omega_d*t)); % plot the real part of X against time
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Response of Mass-Spring-Damper System');
grid on;
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Assembly dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by