In: Mechanical Engineering
Fix the bugs in this matlab program so that it solves.
clear
clf
clc
time = linspace(0, 5, 100);
m = 1; k = 100; c = 1; delta = 0.2;
[period, response] = Exmp(m, k, c, delta, time);
plot(time, response)
grid
%Exmp(m, k, c, delta, time)
%
%________________________________________
function [T, x] = Exmp(m, k, c, delta, t)
omega = sqrt(k/m);
cC = 2*m*omega;
if c>= cC
disp('Not an underdamped system')
T = 0; x = 0;
return;
end
% end of if- - - - - - - - - - - - - - - - - - - - -
omegaD = omega*sqrt(1-(c/cC)^2);
T = 2*pi/omegaD;
x =
delta*exp((-c.*t)/2*m).*(cos(omegaD*t)+c/(2*m*omegaD).*sin(omegaD*t));
end
% end of the function - - - - - - - - - - - - - - - -
cilck on new symbol on top of left corner
click on function and write as follow
save the function
Now write another script
Press the Run