Matrix in Romberg method
Afficher commentaires plus anciens
Hi! I´ve been asked to create a code that works with the Romberg Integration method, I´ve tried to create a matrix that displays the procedure, so to speak, but I can´t seem to be able to create it. I´m still new to Matlab so I wanted to ask for some help on how to do it. Thanks in advance :)
Here´s my code
li = -3;
ls = 3;
k = 4;
n = 2.^(0:k-1);
i = [0:1:n(k)];
% disp(i([1:n+1])
f =@(xi) (log(4*(xi.^2)+4));
arr = [];
for c = 1:k
difx = (ls - li)./n([1:k]);
xi = li + (i([1:n(c)+1]).*difx(c));
a = numel(xi);
sum1 = [f(xi(1)) 2.*f(xi(2:a-1)) f(xi(a))];
est = (difx(c)/2)*(sum(sum1));
arr = [arr est];
end
%Here´s the start of the actual method and my attempt at the matrix
val = arr
fun =@ (z,y) (((4.^(z-1)).*val((2:k),y)-val((1:k-1),y))./((4.^(z-1))-1));
for y = 1:k
for x = 1:3
z = [2:1:k]
fil = fun(z,y)
nuz = k - [k-1:-1:1]
filz = zeros(1,nuz);
val = [val; fil filz]
end
end
disp(arr)
Réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!