Question

I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding?

(a)Use Euler method to find the difference equation for the following IVP (initial value problem). Please Type your work. (Du

b)

(c) and (d)

%% Matlab code %%

clc;
close all;
clear all;
format long;
f=@(t,y)y*(1-y);
y(1)=0.01;

%%%% Exact solution
[t1 y1]=ode45(f,[0 9],y(1));
figure;
plot(t1,y1,'*');
hold on
% Eular therom
M=[32 64 128];
T=9;
fprintf(' M Max error \n' );
for n=1:length(M)
k=T/M(n);
t=0:k:T;
for h=1:length(t)-1
y(h+1)=y(h)+k*f(t(h),y(h));
end
plot(t,y);
hold on
%%% Exact solution
[t y2]=ode45(f,t,y(1));
Mer=max(abs(y2-y'));
fprintf(' %d %f \n',M(n),Mer);
end

legend('Exact solution','M=30','M=64','M=128');
xlabel('t');
ylabel('y(t)');

OUTPUT:

Exact solution M-30 М-64 M-128 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 9 3 4 5 6

(a)Use Euler method to find the difference equation for the following IVP (initial value problem). Please Type your work. (Due on March 5th) dt(, yo 0.01 (b) Calculate the numerical solution for 0 s t S T using k and M T where k = and T = 9 for M 32,64, 128. Using programming languages such as Ct+, MATLAB, eto. (c) Graph those numerical solutions versus exact solution. (Due on March 19th) 32, 64, 128 where (d) Find the maximum error for each M maximum error eo naxj 1, M+1|y(5)-m y(t,) exact solution of the IVP at t - tj; y, solution of difference equation at t t, calculated by the computer. (Due on April 5th)
Exact solution M-30 М-64 M-128 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 9 3 4 5 6
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (a)Use Euler method to find the difference equation for the following IVP (initial value problem)...

    i really just need help with part c and d. thank you! (a)Use Euler method to find the difference equation for the following IVP (initial value problem). Please Type your work. (Due on March 5th) dt(, yo 0.01 (b) Calculate the numerical solution for 0 s t S T using k and M T where k = and T = 9 for M 32,64, 128. Using programming languages such as Ct+, MATLAB, eto. (c) Graph those numerical solutions versus exact...

  • Hi I need help understanding this matlab code. Can you add comments or at least state what the lines in this code are doing. Thanks! close all; clear all;clc; t=1:0.025:5; desired=5*sin(2*3.*t); noi...

    Hi I need help understanding this matlab code. Can you add comments or at least state what the lines in this code are doing. Thanks! close all; clear all;clc; t=1:0.025:5; desired=5*sin(2*3.*t); noise=5*sin(2*50*3.*t); refer=5*sin(2*50*3.*t+ 3/20); primary=desired+noise; subplot(4,1,1); plot(t,desired); ylabel('desired'); subplot(4,1,2); plot(t,refer); ylabel('refer'); subplot(4,1,3); plot(t,primary); ylabel('primary'); order=2; mu=0.005; n=length(primary) delayed=zeros(1,order); adap=zeros(1,order); cancelled=zeros(1,n); for k=1:n, delayed(1)=refer(k); y=delayed*adap'; cancelled(k)=primary(k)-y; adap = adap + 2*mu*cancelled(k) .* delayed; delayed(2:order)=delayed(1:order-1); end subplot(4,1,4); plot(t,cancelled); ylabel('cancelled');

  • t0 = 0; tf = 20; y0 = [10;60]; a = .8; b = .01; c...

    t0 = 0; tf = 20; y0 = [10;60]; a = .8; b = .01; c = .6; d = .1; [t,y] = ode45(@f,[t0,tf],y0,[],a,b,c,d); u1 = y(:,1); u2 = y(:,2); % y in output has 2 columns corresponding to u1 and u2 figure(1); subplot(2,1,1); plot(t,u1,'b-+'); ylabel('u1'); subplot(2,1,2); plot(t,u2,'ro-'); ylabel('u2'); figure(2) plot(u1,u2); axis square; xlabel('u_1'); ylabel('u_2'); % plot the phase plot %---------------------------------------------------------------------- function dydt = f(t,y,a,b,c,d) u1 = y(1); u2 = y(2); dydt = [ a*u1-b*u1*u2 ; -c*u2+d*u1*u2 ]; end Only...

  • Can you please help me with this question. Much appreciated. So I have a sample code,...

    Can you please help me with this question. Much appreciated. So I have a sample code, but we need to change the code in a way that fits the problem. A planar slab of material is initially at a temperature of 300 K. At the time t=0, microwave radiation is directed at the material, leading to internal heat generation that is uniform within the material. The sides of the slab experience negligible heat losses and a water bath maintains the...

  • I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT...

    I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT WE HAVE A SUB AND HE DIDN'T TEACH IT! ITS EULER AND IMPROVED EULER IN MATLAB! HERE IS THE LINK FOR THE IMAGE FILE THAT SHOWS THE FULL INSTRUCTIONS FOR THE CODE. https://imgur.com/a/gjmypLs Also, here is my code so far that I borrowed form an old assignment but the data is all wrong and the application of the code is slightly different so either...

  • I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3:...

    I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3: Post each trans me general ledger working papers provideo teach transaction in the general journal to the general ledger. Use s provided in your packet. Posting is the process of transferring general journal entry information to the seneral ledger. Fach number you post should be properly Cross-referenced Helpful Hints by: recording the general journal page number (ex. G1, G2, etc.) in the Posting Reference...

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