to find area of parabola?

조회 수: 9 (최근 30일)
RS
RS 2013년 4월 6일
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','-');

채택된 답변

bym
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
  댓글 수: 1
RS
RS 2013년 4월 6일
Thank you!! I have another problem
x1=7.8;
x2=8.5;
y1=0.96;
y2=0.94;
p1 = polyfit([x1 x2], [y1 y2], 2);
b1= polyval(p1,1);
m1=polyval(p1,2)-b1;
x3=8.25;
x4=8.25;
y3=0;
y4=.99;
p2 = polyfit([x3 x4], [y3 y4], 2);
b2 = polyval(p2, 1);
m2 = polyval(p2, 2) - b2;
I got x value = -1.2867; from which co-ordinate this value corresponds to? Actually I want to compute intersection of two line with respect to x=[7.8 8.25 8.5]; y=[0.96 0.99 0.94]; over which those two lines are plotted?
x=[7.8 8.25 8.5];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
f=polyval(p,x);
plot(x,y,'o',x,f,'-');
hold on;
line([7.8 8.5],[0.96 0.94]);
hold on;
line([8.25 8.25],[0 0.99]);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vehicle Scenarios에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by