Trapezoidal rule in MATLAB
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
This is my code so far.
function v = velocity(x, route)
load route;
d = distance_km;
y = speed_kmph;
dd=0:distance_km(end);
pp=spline(d,y);
v = ppval(pp, x);
plot(d,y,'ro');
hold on
h=fplot(@(x)ppval(pp,x),[d(1),d(end)], '- b')
hold off
if (x<0 | x>d(end)) error ('Fel') end end
This is the given code that I'm supposed to use when using trapezoidal rule:
function T = trapets(func, a, b, n)
h=(b-a)/n;
x = linspace(a,b,n+1);
fx = func(v);
T = h*(sum(fx)-(fx(1)+fx(end))/2);
end
How does the trapezoidal rule work in MATLAB? I don't really know where to begin.
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre Splines en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!