Question

2. Differential Equation (5 points) Using (i) Eulers method and (ii) modified Eulers method, both with step size h-0.01, to

Please show Matlab code and Simulink screenshots

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

dxdt-@ (t , X) 3qrt (x*t/ (Χ. ^2+t . ^2) ) ; h -0.01 t = 0:h:2; xeuler zero3 (1, length (t) ) ; x mod euler zero3 (1, lengthEuler 1.000000 1.056033 1.155296 1.273355 1.401232 1.534560 1.671064 1.809486 1.949097 2.089454 2.230281 5 Modified Euler 1.0Euler Method vs Modifed Euler Method 2.4 r 2.2 1.8 1.6 1.4 Euler Method Modified Euler Method 1.2 0 0.2 0.40.6 0.8 1 12 1.416

Text :-

dxdt = @(t,x) sqrt(x*t/(x.^2+t.^2));
h = 0.01;
t = 0:h:2;      % time vector (t0,t1,...tn)
x_euler = zeros(1,length(t));      % Initializing Euler solution vector having same size as time vector
x_mod_euler = zeros(1,length(t));  % Initializing modified Euler solution

x_euler(1) = 1;             % Initial Conditions
x_mod_euler(1)=1;

for k = 2:length(t)
x_euler(k) = x_euler(k-1) + h*dxdt(t(k-1),x_euler(k-1));
x_mod_euler(k) = x_mod_euler(k-1) + (h/2)*(dxdt(t(k-1),x_mod_euler(k-1)) + dxdt(t(k),x_euler(k)));
end

% Comparing Results in table (Intermediate Values)
fprintf("\n %8s %16s %20s\n","t","Euler","Modified Euler")
fprintf(" %8.2f %16.6f %20.6f\n",[t(1:20:end)',x_euler(1:20:end)',x_mod_euler(1:20:end)'].')
% Ploting Both on Same Graph
p = plot(t,x_euler,'-.',t,x_mod_euler,'--');
p(1).LineWidth = 1.6;       p(2).LineWidth = 1.6;
legend(["Euler Method","Modified Euler Method"],'Location','Best')
xlabel('t');    ylabel("x(t)");      title("Euler Method vs Modifed Euler Method")

Simulink :-

1 Scope Integrator Clock u(2) sqrt(u(1) u(2)/(u(1)2+ u(2)A2)) Fcn Bus Creator

Scope O/P :-

2.2 1.2 0.2 0.4 0.6 0.8 1.2

Add a comment
Know the answer?
Add Answer to:
2. Differential Equation (5 points) Using (i) Euler's method and (ii) modified Euler's method, bo...
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