error in line1and 4

조회 수: 2 (최근 30일)
firas
firas 2023년 5월 11일
댓글: Torsten 2023년 5월 11일
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_n = 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);
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Response of Mass-Spring-Damper System');
grid on;

답변 (1개)

Chunru
Chunru 2023년 5월 11일
Those are comments which shoud start with %
% Calculate the response function using the equation of motion:
omega_n = sqrt(k / m); % natural frequency
Unrecognized function or variable 'k'.
zeta = c / (2 * sqrt(m * k)); % damping ratio
omega_n = 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);
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Response of Mass-Spring-Damper System');
grid on;
  댓글 수: 2
firas
firas 2023년 5월 11일
it says vakue assigned to variable might be unsured (omega_n);
omega_n = omega_n * sqrt(1 - zeta^2); % damped natural frequency
Torsten
Torsten 2023년 5월 11일
It means that you defined a variable, but you didn't use this variable in the sequel. Thus deleting the line where you defined the variable would not change anything in the results from the code - usually an indicator that you made a mistake.

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

카테고리

Help CenterFile Exchange에서 MuPAD에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by