MATLAB question! 4. (a) Modify the code, to compute and plot the quantity E = 1/2mv^2 +...

70.2K

Verified Solution

Question

Advance Math

MATLAB question!

4. (a) Modify the code, to compute and plot the quantity E =1/2mv^2 + 1/2ky^2 as a function of time. What do you observe? Isthe energy conserved in this case?

(b) Show analytically that dE/dt < 0 for c > 0 while dE/dt> 0 for c < 0.

(c) Modify the code to plot v vs y (phase plot). Comment on thebehavior of the curve in the context of the motion of the spring.Does the graph ever get close to the origin? Why or why not?

given code
---------------------------------------------------------------

clear all;   
m = 4; % mass [kg]
k = 9; % spring constant [N/m]
c = 4; % friction coefficient [Ns/m]
omega0 = sqrt(k/m); p = c/(2*m);
y0 =-0.8; v0 = 0.3; % initial conditions
[t,Y] = ode45(@f,[0,15],[y0,v0],[],omega0, p); % solve for0y = Y(:,1); v = Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'ro-',t,v,'b+-');% time series for y andv
grid on; axis tight;
%---------------------------------------------------
function dYdt = f(t,Y,omega0,p); % function defining the DE
y = Y(1); v = Y(2);
dYdt=[ v ; -omega0^2*y-2*p*v]; % fill-in dv/dt
end

-----------------------------------------------------------------------------------------

Answer & Explanation Solved by verified expert
4.1 Ratings (850 Votes)
clear allm 4 mass kgk 9 spring    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students