Question

USING MATLAB

Please post code1. Solve the 2nd order differential equation ?+89 +15y-sin(t), y(0)-1,?(0)-2 symbolically and numerically, and plot both results together over the time interval 0,10 sec. Provide appropriate labels on both axes, a title, and a legend that denotes each solution. Check your symbolic answer by using the Matlab DIFF function to compute the appropriate derivatives and then substituting them into the differential equation.

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

PLEASE REFER BELOW CODE

close all
clear all
clc

syms y(t)
%Solving DE symbolically

%given equation
eqn = diff(y,t,2) + 8 * diff(y,t,1) + 15 * y == sin(t);
Dy = diff(y,t);
cond = [y(0) == 1,Dy(0)==2]; %initial condition
ySol(t) = dsolve(eqn,cond);

t = 0:0.1:10;
hold on
plot(t,ySol(t))

%Solving numeriaclly
tspan = [0 10];
y0 = [1 2]; %initial condition
[t,y] = ode45(@dydt,tspan,y0);
plot(t,y(:,1))
hold off
title('Solution of DE');
xlabel('t');
ylabel('y(t)');
legend('Symbolically','Numerically')


function doty = dydt(t,y)
doty = [y(2); -8 * y(2)-15 * y(1)+sin(t)];
end

PLEASE REFER BELOW OUTPUT

Solution of DE 1.2 r Symbolically Numerically 0.8 0.6 0.4 0.2 -0.2 0 1 234 5 6 78 9 10

Add a comment
Know the answer?
Add Answer to:
USING MATLAB Please post code 1. Solve the 2nd order differential equation ?+89 +15y-sin(t), y(0)-1,?(0)-2 symbolically...
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
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