Question

In Matlap, Please do Matlap code Consider the second order differential equation y” + 4y = 0, y(0) = 1, y(0) = 1 1. Use ode45 to solve this equation for y ove

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • Inorder to solve a 2nd order ODE with a matlab's ode solver, we have to convert it to state space form first.
  • The state space form can be obtained by passing the ODE equatino to odeToVectorField() funciton.
  • Then, create a matlab fucntion out of this state space and pass it to ode45.
  • Ode45 return a vector of x values and a 2xn vector y of y and y' values.
  • the first row of y will be reqiured y values.
  • the amplitude of the signal can be found out by using max() funcntion on y(1,:)
  • the time period can be found by calculating the x distance between the two consectutive value od result obtained from findpeaks() funciton.

program:

syms y(t)

ss = odeToVectorField(diff(y,2)+4*y==0);

f = matlabFunction(ss,'vars',{'t','Y'});

[x, yv] = ode45(f,[0 20],[1 1]);

y = yv(:,1)

ymax = max(y(11:end))

[peaks,locs] = findpeaks(y);

yperiod = x(locs(4))-x(locs(3))

outputs:

sol = ode45 (f, [020],[1 1]) sol = struct with fields: solver: ode45 extdata: [lxl struct] x: [1x53 double] y: [2x53 double

Add a comment
Know the answer?
Add Answer to:
In Matlap, Please do Matlap code Consider the second order differential equation y” + 4y =...
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