필터 지우기
필터 지우기

Average in a summation

조회 수: 1 (최근 30일)
Omar
Omar 2014년 2월 11일
편집: Azzi Abdelmalek 2014년 2월 11일
Say I have an Excel File with X and Y columns.
How can I compile a program to do the (average between 2, X terms) times (the difference between the 2, Y terms) for n number of terms in consecutive order.
I tried Sum([X(1:end-1) + X(2:end)]/2.* (y(2:end)-Y(1:end))) for some reason the actual value was half the amount from what I got so I'm not sure if I made and error in my coding.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 11일
편집: Azzi Abdelmalek 2014년 2월 11일
You did 2 errors
X=rand(10,1);
Y=rand(10,1);
sum((X(1:end-1)+X(2:end))/2.*(Y(2:end)-Y(1:end-1)))
sum instead of Sum
Y(2:end)-Y(1:end) is not correct (different sizes)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by