Question

I need to use ode45 or ode23 in matlab to plot the change of y1,y2 and...

I need to use ode45 or ode23 in matlab to plot the change of y1,y2 and y3 with time

y0=2.8

and the following first order differential equations :

dy1/dt=(y0-1.625y1)/6.25

dy2/dt=(y1-1.625y2)/6.25

dy3/dt=(y2-1.625y3)/6.25

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

Code:

clc
clear

tspan = [0 10];
y0 = 2.8;
y02 = 0;
y03 = 0;


[t,y1] = ode45(@(t,y1) (y0-1.625*y1)/6.25, tspan, y0);
plot(t,y1,'-ro');
hold on
[t,y2] = ode45(@(t,y2) (y1(end)-1.625.*y2)./6.25, tspan, y02);
plot(t,y2,'-ks');
[t,y3] = ode45(@(t,y3) (y2(end)-1.625*y3)/6.25, tspan, y03);
plot(t,y3,'-b^');
legend('y1', 'y2', 'y3');
hold off

Output:

Add a comment
Know the answer?
Add Answer to:
I need to use ode45 or ode23 in matlab to plot the change of y1,y2 and...
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