Use matlab In Problems 5-10 use a numerical solver and Euler's method to obtain a four-decimal approximation of the indicated value. First use h 5 0.1 and then use h 5 0.05. 8. y'=xy+ sqrt(y), y(0)-1, y(0.5) I tried this method, but it gives me errors "un recongnized function or variable at 'xy'. Error in live 5 and error in line 17 close all clear clc f=@(x,y) xy+sqrty; % Given ODE x0=0; xf=0.5; % Interals of x yo=1; % Intital condition h1=0.1; % Step Size 1 y1=euler (x0, yo, xf, h1, f); fprintf('For h=0.1, y(0.5) - %.4f/n', y1(end)) y2=euler (x0, yo, xf, h2, f); fprintf('For h=0.05, y(0.5) - %.4f/n', y2(end)) function y=euler (x0, yo, xf, h, f) y(1)=y0; x=x0:h:xf; for i=1:length(x)-1 f1-f(x(i), y(i)); y(i+1)=y(i) +h*f1; %Euler's Update end end

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.7: Do While Loops
Problem 6E: (Numerical analysis) Here’s a challenging problem for those who know a little calculus. The...
icon
Related questions
Question
Use matlab In Problems 5-10 use a numerical solver and Euler's method to obtain a four-decimal
approximation of the indicated value. First use h 5 0.1 and then use h 5 0.05. 8. y'=xy+ sqrt(y), y(0)=1, y(0.5) I tried this method,
but it gives me errors "un recongnized function or variable at 'xy'. Error in live 5 and error in line 17
close all
clear
clc
f=@(x,y) xy+sqrty; % Given ODE
x0=0; xf=0.5; % Interals of x
y0=1; % Intital condition
h1-0.1; % Step Size 1
y1=euler (x0, yo, xf, h¹, f);
fprintf('For h=0.1, y(0.5) - %.4f/n', y1(end))
y2=euler (x0, yo, xf, h2, f);
fprintf('For h=0.05, y(0.5)=%.4f/n', y2(end))
function y=euler (x0, yo, xf, h, f)
y(1)=y0; x-x0:h:xf;
for i=1:length(x) -1
f1-f(x(i), y(i));
y(i+1)=y(i)+h*f1; %Euler's Update
end
end
Transcribed Image Text:Use matlab In Problems 5-10 use a numerical solver and Euler's method to obtain a four-decimal approximation of the indicated value. First use h 5 0.1 and then use h 5 0.05. 8. y'=xy+ sqrt(y), y(0)=1, y(0.5) I tried this method, but it gives me errors "un recongnized function or variable at 'xy'. Error in live 5 and error in line 17 close all clear clc f=@(x,y) xy+sqrty; % Given ODE x0=0; xf=0.5; % Interals of x y0=1; % Intital condition h1-0.1; % Step Size 1 y1=euler (x0, yo, xf, h¹, f); fprintf('For h=0.1, y(0.5) - %.4f/n', y1(end)) y2=euler (x0, yo, xf, h2, f); fprintf('For h=0.05, y(0.5)=%.4f/n', y2(end)) function y=euler (x0, yo, xf, h, f) y(1)=y0; x-x0:h:xf; for i=1:length(x) -1 f1-f(x(i), y(i)); y(i+1)=y(i)+h*f1; %Euler's Update end end
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Maximum Flow
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr