-
-
Save Makazone/7286173e448dcaa7c9e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [y] = Fred_II_Rect(K,f,a,b,h) | |
x = a:h:b; | |
n = size(x,2); | |
wt = 1/2; | |
wj = 1; | |
A = zeros(n); | |
for i = 1:n | |
A(i,1)= h*wt*K(x(i),x(1)); | |
for j=2:n-1 | |
A(i,j)= h*gtwj*K(x(i),x(j)); | |
end; | |
A(i,n)= h*wt*K(x(i),x(n)); | |
A(i,i)= A(i,i)+ 1; | |
end; | |
B = zeros(n,1); | |
for j=1:n | |
B(j,1) = f(x(j)); | |
end; | |
y = A\B; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
close | |
all clear | |
all clc | |
format long; | |
N = 10; | |
h = 1 / N; | |
a = 0; | |
b = 1; | |
epsilon = 0.01; | |
K = @(x1,s)(x1 + s)*epsilon; | |
f = @(x1)x1; | |
y_approx1 = Fred_II_Rect(K,f,a,b,h); | |
epsilon = 0.005; | |
K = @(x1,s)(x1 + s)*epsilon; | |
y_approx2 = Fred_II_Rect(K,f,a,b,h); | |
hold on | |
plot(a:h:b, y_approx1); | |
plot(a:h:b, y_approx2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment