Summing parts of an array??

80 views (last 30 days)
Kevin
Kevin on 29 Jul 2014
Answered: Azzi Abdelmalek on 29 Jul 2014
I have the following lines of code:
D=(8./(TSR.*9)).*(F.*(sin(relative_wind).^2).*(cos(relative_wind)-((TSR_local).*(sin(relative_wind)))).*(sin(relative_wind)+((TSR_local).*(cos(relative_wind)))).*(1-(Cd./Cl).*cot(relative_wind)).*(TSR_local.^2));
Cp=sum(D);
D is a 9x1 array. However I only want to sum the first 8 values in the array. Could anybody please show me how to do this as my current code is summing all 9 values?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 29 Jul 2014
sum(D(1:8))

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!