Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with MATLAB code for part (c) using the function/equation from the t

ID: 2246561 • Letter: P

Question

Please help with MATLAB code for part (c) using the function/equation from the top of the picture (2)

Part (c) includes

i. x(0) = 1, x'(0) = 0

ii. x(0) = 0, x'(0) = 1

iii. x(0) = 1, x'(0) = 1

Use the following values and plot x(t) vs t for all the following conditions on the same plot: i. m = 1 kg, k = 900 N/m, c = 0 N s/m, x(0) = 1, i(0) = 0, f(t) = 0 ii. m = 1 kg, k = 900 N/m, c = 5 N s/m, x(0) = 1, i(0) = 0, f (t) = 0 iii. m = 1 kg, k = 900 N/m, c = 20 N s/m, x(0) = 1, i(0) = 0, f(t) = 0 iv. m = 1 kg, k = 900 N/m, c = 40 N s/m, x(0) = 1, i(0) = 0, f(t) = 0 v. m = 1 kg, k = 900 N/m, c = 60 N s/m, x(0) = 1, x(0) = 0, f(t) = 0 (b) Use the following values and plot x(t) vs t for all the following conditions on the same plot. Set m = 1 kg, k = 900 N/m, c = 2 N s/m, x(0) = 1, x = 0. Plot x(t) vs t on the same plot. i. f(t) = cos 10t ii. f(t) = cos 25t iii. f(t) = cos 30t iv. f(t) = cos 45t v. f(t) = cos 60t (c) Use the following values and plot x(t) vs t for the all the following conditions on the same plot. Set m = 1 kg, k = 90 N/m, c = 2 N s/m, f(t) = 0. i. x(0) = 1, x(0) = 0 ii. x(0) = 0, x(0) = 1 iii. x(0) = 1, x(0) = 1 Write your own function called myODE4RK which takes arguments similar to ode45 and uses the 4th order Runge-Kutta Method to solve a system of first order differential equations. Test your function on the same inputs as above and make sure that the result from your function matches that of MATLAB.

Explanation / Answer

Here is a matlab code that runs in R2015b.

syms y(t) p w t
p = 0;
Deq = diff(y,2) + p*diff(y) + 2*y ==0;
Y = dsolve(Deq, diff(y(0)) == 0, y(0) == 0);
Y = simplify(Y, 'steps', 20);
Yfcn = matlabFunction(Y)
t = linspace(0, 10, 25);
w = linspace(0, 2*pi, 50);
[T,W] = meshgrid(t,w);
C = 1;
Y = Yfcn(C,T,W);
figure(1)
surf(T, W, Y)
grid on
xlabel('Time')
ylabel('Angular Frequency (rad)')
zlabel('Y')

you can change the value of diff(y(0)) as x'(0) and y(0) as x(0).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote