Simpson's Rule to find total work
조회 수: 1 (최근 30일)
이전 댓글 표시
If I'm given time=[0,#,#,#,#,#] and velocity=[#,#,#,#,#,#] and Force=[#,#,#,#,#,#], how could I use Simpson's rule to find the total work in this time? I know work is area under curve of Force vs distance, and I know distance/position is area under curve of velocity vs time.
So far I have this:
n=6
sum2=0
sum1=0
sumn=0
P(1)=0
for i=0:n
if i==0
sum0= v(i+1)
elseif i==n
sumn = v(i) %TA wrote v(i+1)?
elseif mod(i,2)==1
sum1=sum1 + v(i+1)
elseif mod(i,2)==0
sum2=sum2+v(i+1)
end
delt=(t(n)-t(1))/3
area1=delt*(sum0 + sumn + 4*sum2 + 2*sum2)
if i>1
P(i)= P(i-1) +area1
end
end
1) Not sure if I found the correct position values. Is it wrong to assume P(1)=0?
2)for total work, Would I repeat the same for loop, but now with Force and Position values?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!