Question

eview File Edit View 66 180s volw à MAE305 Project 5.pdf (1 page) Project 5 1. Solve ollowing initial value problem to obtain

matlab code

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

du dt it; ?什 dt oo, o.ouCl dt 2. 2 Analtial dcq Ck tseを .-5 t

clc;clear all;
%Euler method
t1(1)=0;
u1(1)=0;
h=[0.01,0.1,0.5];
figure
for j=1:3
for i=1:100
u1(i+1)=u1(i)+((50-10*t1(i))*h(j));
t1(i+1)=t1(i)+h(j);
end
plot(t1,u1)
hold on
end
xlabel('t')
ylabel('u')
title('Euler method')
legend('h=0.01','h=0.1','h=0.5')


%RK method
t2(1)=0;
u2(1)=0;
figure
for j=1:3
for i=1:100
k1=h(j)*(50-(10*t2(i)));
k2=h(j)*(50-(10*(t2(i)+0.5*h(j))));
k3=h(j)*(50-(10*(t2(i)+0.5*h(j))));
k4=h(j)*(50-(10*(t2(i)+h(j))));
du=(1/6)*(k1+(2*k2)+(2*k3)+k4);
u2(i+1)=u2(i)+du;
t2(i+1)=t2(i)+h(j);
end
plot(t2,u2)
hold on
end
xlabel('t')
ylabel('u')
title('RK4 method')
legend('h=0.01','h=0.1','h=0.5')

%analtical
t=0:0.01:50;
u=-5*t.^2+(50*t);
figure
plot(t,u)
xlabel('t')
ylabel('u')
title('Analtical equation')

Euler method 2000 h-0.01 h-0.1 -h=0.1 h=0.5 2000 4000 6000 8000 -10000 0 5 10 15 20 25 30 35 40 45 50

RK4 method 2000 h=0.01 h-0.1 h=0.5 2000 400 6000 8000 -10000 0 5 10 15 20 25 30 35 40 45 50

Analtical equation 2000 -2000 400 6000 8000 -10000 0 5 10 15 20 25 30 35 40 45 50

Add a comment
Know the answer?
Add Answer to:
matlab code eview File Edit View 66 180s volw à MAE305 Project 5.pdf (1 page) Project 5 1. Solve ollowing initial value problem to obtain u(5), du dt 10t+50, u) (a) Use Euler's Method wit...
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