to find area of parabola?
2 次查看(过去 30 天)
显示 更早的评论
parabola going from three point (7.8 0.96), (8.25 0.99), (8.55 0.94), how can I compute area under the parabola?
x=[7.8 8.25 8.55];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
f=polyval(x,p);
plot('x','y','o','x','f','-');
0 个评论
采纳的回答
bym
2013-4-6
x=[7.8 8.25 8.55];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
%f=polyval(x,p); x & p should be reversed
%plot('x','y','o','x','f','-'); read plot documentation
% method 1
t = linspace(x(1),x(3));
yhat = polyval(p,t);
a1 = trapz(t,yhat);
% method 2
f = @(v) p(1)*v.^2+p(2)*v+p(3);
a2 = quadgk(f,x(1),x(3));
a1,a2
a1 =
0.7344
a2 =
0.7344
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!