Question

1. Apply Eulers Method with step size h=0.1 on [0, 1] to the initial value problems in Exercise 3. Print a table of the t va

3. Use separation of variables to find solutions of the IVP given by y) = 1 and the following differential equations: (a) y=

Exercise 3 is used towards the question. Please in MATLAB coding.

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

a)

clc

clear all

close all

format short

f=@(t,y) t;

[T,Y]=eulerSystem(f,[0,1],1,0.1);

T=T(:);

Y=Y(:);

table(T,Y)

function [t,y]=eulerSystem(Func,Tspan,Y0,h)

t0=Tspan(1);

tf=Tspan(2);

N=(tf-t0)/h;

y=zeros(length(Y0),N+1);

y(:,1)=Y0;

t=t0:h:tf;

for i=1:N

y(:,i+1)=y(:,i)+h*Func(t(i),y(:,i));

end

end

b)

clc

clear all

close all

format short

f=@(t,y) t^2*y;

[T,Y]=eulerSystem(f,[0,1],1,0.1);

T=T(:);

Y=Y(:);

table(T,Y)

function [t,y]=eulerSystem(Func,Tspan,Y0,h)

t0=Tspan(1);

tf=Tspan(2);

N=(tf-t0)/h;

y=zeros(length(Y0),N+1);

y(:,1)=Y0;

t=t0:h:tf;

for i=1:N

y(:,i+1)=y(:,i)+h*Func(t(i),y(:,i));

end

end

Add a comment
Know the answer?
Add Answer to:
Exercise 3 is used towards the question. Please in MATLAB coding. 1. Apply Euler's Method with...
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