help me, why is it invalid use of operator?

조회 수: 1 (최근 30일)
Jefferson Pons
Jefferson Pons 2020년 7월 21일
댓글: David Hill 2020년 7월 21일
can you guys help me? this is the code im having problem with:
% Simpson's 1/3 Rule for finding integration of x
the function that i want to use is this:
please help me. thank you!

답변 (1개)

David Hill
David Hill 2020년 7월 21일
Not sure if you have additional constraints, but if your functions are all polynomials, the polyint function works well.
p=[-.0729,1.171,-13.8,4,-1];
intP=diff(polyval(polyint(p),[a,b]));%where a and b are the lower and upper bounds
  댓글 수: 2
David Hill
David Hill 2020년 7월 21일
f=@(x)-.0729*x.^4+1.171*x.^3-13.8*x.^2+4*x-1;%here is how you write the function
David Hill
David Hill 2020년 7월 21일
Where a,b,and n are input like above
f=@(x)-.0729*x.^4+1.171*x.^3-13.8*x.^2+4*x-1;
x=linspace(a,b,n+1);
y=f(x);
intF=(b-a)/3/n*(f(a)+f(b)+4*sum(y(1:2:end))+2*sum(y(2:2:end)));

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

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by