Question

These instructions are written with the assumption that code will be done in matlab. You might fi...

These instructions are written with the assumption that code will be done in matlab. You might find the following built in commands useful: length, plot, xlabel, ylabel, title, legend, fzero, plot, disp, axis, axes, min, max.

1. A spring-mass system has the following position y(t) and velocity v(t) functions: y(t) = e −0.5t sin(2t) + √ 3e −0.5t cos(2t) v(t) = e −0.5t (2√ 3 − 0.5) sin(2t) − 0.5(4 + √ 3)e −0.5t cos(2t) where the units are in seconds and meters. Make a well-labeled graph that shows position and velocity from t = 0 to t = 20.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

close all
clear
clc

t = 0:0.01:20;
y = exp(-0.5*t).*sin(2*t) + sqrt(3)*exp(-0.5*t).*cos(2*t);
v = exp(-0.5*t) * (2*sqrt(3) - 0.5) .* sin(2*t) - 0.5*(4 + sqrt(3)) * exp(-0.5*t) .* cos(2*t);
plot(t,y,t,v), xlabel('t (s)'), ylabel('Position (m) & Velocity (m/s)')
legend('Position, y(t)', 'Velocity, v(t)')

Plot:

3 Position, y(t) Velocity, v(t) 2 0 -1 16 18 10 12 14 0 2 6 8

Add a comment
Know the answer?
Add Answer to:
These instructions are written with the assumption that code will be done in matlab. You might fi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • These instructions are written with the assumption that code will be done in matlab. You might fi...

    These instructions are written with the assumption that code will be done in matlab. You might find the following built in commands useful: length, plot, xlabel, ylabel, title, legend, fzero, plot, disp, axis, axes, min, max. 2. Numerical Integration (Quadrature). Write FOUR of your own numerical integration routines. One should use left-end, right-end, or mid-points, another should use the trapezoid method, another should use Simpson’s method, and the fourth should use either Guassian Quadrature or Romberg’s method. Use your four...

  • You have the matrix below: a) 9 10 11 12 What will be displayed by the code: A(2:3,2:3) What will be displayed when you run the code below? b) a-0 while a<10 aa+3: end disp (a) d) Give the st...

    You have the matrix below: a) 9 10 11 12 What will be displayed by the code: A(2:3,2:3) What will be displayed when you run the code below? b) a-0 while a<10 aa+3: end disp (a) d) Give the steps to find the roots of the following linear equation using MATLAB. rs + 2x4-5x3 + 7x2 + 12x + 20 = 0 a) Give MATLAB commands to plot, on the same figure, the two functions: f(t) = 3t2 +2t-0.5 g(c)-2t...

  • MATLAB code for a double pendulum. Please explain each lines for these codes pls. -------------------------------------...

    MATLAB code for a double pendulum. Please explain each lines for these codes pls. ---------------------------------------------------------------------------- clc close all clear all %---------Parameters------------------------------------------------------ L1=1; L2=1 ; M_1=2 ; M_2=1; G=9.8; %---------initial condition----------------------------------------------- tspan=30; theta1=3; theta1_prime=0; theta2=2.5; theta2_prime=0; y0=[theta1 theta1_prime theta2 theta2_prime]; [t,y]=ode45(@pend, [0 ,tspan],[ 3 0 2 0]); %---position of mass 1 and mass 2---------------------------------------- x1=L1*sin(y(:,1)); y1=-L1*cos(y(:,1)); x2=L1*sin(y(:,1))+l2*sin(y(:,3)); y2=-L1*cos(y(:,1))-l2*cos(y(:,3)); %------visualizing the result--------------------------------------------- figure(1) plot(x1,y1,'linewidth',2) hold on plot(x2,y2,'r','linewidth',2) h=gca; get(h,'fontSize') set(h,'fontSize',14) xlabel('X','fontSize',14); ylabel('Y','fontSize',14); title('Chaotic Double Pendulum','fontsize',14) fh = figure(1); set(fh, 'color', 'white'); figure(2)...

  • MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax...

    MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax T(i)=t; if t>=(T0/2) while (t>T0/2) t=t-T0; end elseif t<=-(T0/2) while (t<=-T0/2) t=t+T0; end end if abs(t)<=(T0/4) y(i)=1; else y(i)=0; end i=i+1; end plot(T,y),grid, xlabel('Time (sec)'); title('y(t) square wave'); shg disp('Hit return..'); pause %--- a0=1/2; F(1)=0; %dc freq C(1)=a0; for n=1:Nmax a(n)=(2/(n*pi))*sin((n*pi)/2); b(n)=0; C(n+1)=sqrt(a(n)^2+b(n)^2); F(n+1)=n*f0; end stem(F,abs,(C)), grid, title(['Line Spectrum: Harmonics = ' num2str(Nmax)]); xlabel('Freq(Hz)'), ylabel('Cn'), shg disp('Hit return...'); pause %--- yest=a0*ones(1,length(T)); for n=1:Nmax yest=yest+a(n)*cos(2*n*pi*T/T0)+b(n)*sin(2*n*pi*T/T0);...

  • please help me with this MATLAB CODE and explain to me what each line does and...

    please help me with this MATLAB CODE and explain to me what each line does and what is used for? leave your comments as words, not as pictures. ..................................................................................................................................................................... clear all; close all; % For a script file, you better start with clear all and close all                        % However, for a fucntion, you better NOT to start                        % with them %% End of cell mode example %% Plot function t = 0:0.1:5; x1 = sin(2*5*t); x2 = cos(3*7*t);...

  • Only the matlab nlinear equations x 0.75 Determine the roots of these equations using: a) The...

    Only the matlab nlinear equations x 0.75 Determine the roots of these equations using: a) The Fixed-point iteration method. b) The Newton Raphson method. Employ initial guesses of x y 1.2 and perform the iterations until E.<10%. Note: You can use to solve the problems, but you should sol at least two full iterations manually. AB bl Du Thursd 30/3/ 1. For the displacement in Q3 y 10 e cos at 0 St S 4. a) Plot the displacement y...

  • Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2...

    Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...

  • CONVERT THE FOLLOWING MATLAB CODE FROM SOURCE PANEL METHOD TO VORTEX PANEL METHOD: clc;clear all;...

    CONVERT THE FOLLOWING MATLAB CODE FROM SOURCE PANEL METHOD TO VORTEX PANEL METHOD: clc;clear all;close all; Vinf=100; % freestream velocity R=1; % cylinder radius n=4; % number of panels alpha=2; % angle of attack dtheta=2*pi/n; theta=pi+pi/n:-dtheta:-pi+pi/n; X=R*cos(theta); Y=R*sin(theta); for i=1:n % angle of flow with tangent of panel phi(i)=-alpha+atan2((Y(i+1)-Y(i)),(X(i+1)-X(i))); % angle of flow with normal of panel beta(i)=phi(i)+pi/2; x_mid(i)=(X(i+1)+X(i))/2; y_mid(i)=(Y(i+1)+Y(i))/2; S(i)=sqrt((Y(i+1)-Y(i))^2+(X(i+1)-X(i))^2); end % Source Panel Method for j=1:n neighbors(:,j)=[1:j-1 j+1:n]; xi=x_mid(j); yi=y_mid(j); for i=1:n-1 m=neighbors(i,j); Xj=X(m); Yj=Y(m); Xj1=X(m+1); Yj1=Y(m+1); A=-(xi-Xj)*cos(phi(m))-(yi-Yj)*sin(phi(m));...

  • Using matlab, write the code and plot the graph for the following equations. The x axis...

    Using matlab, write the code and plot the graph for the following equations. The x axis would be theta from 0 deg to 360 deg while the y axis would be angular or tangential position, velocity and acceleration. 10 100 E7360 AB- eD100mm sin 1O-Sn 2To ne cose, t Cas 2 3 4 O,= To (reano,re bease-feo, sene-Feo 6 as ) Cos O2 10 100 E7360 AB- eD100mm sin 1O-Sn 2To ne cose, t Cas 2 3 4 O,= To...

  • I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear...

    I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear all; format long; f=@(t,y)y*(1-y); y(1)=0.01; %%%% Exact solution [t1 y1]=ode45(f,[0 9],y(1)); figure; plot(t1,y1,'*'); hold on % Eular therom M=[32 64 128]; T=9; fprintf(' M Max error \n' ); for n=1:length(M) k=T/M(n); t=0:k:T; for h=1:length(t)-1 y(h+1)=y(h)+k*f(t(h),y(h)); end plot(t,y); hold on %%%...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT