フィルターのクリア

Cumulative Frequency

8 ビュー (過去 30 日間)
Mayu
Mayu 2011 年 12 月 12 日
When I do a calculation with a cumulative frequency, for example:
S2 %Column vector
B=[];
for i=1:length(S2)-1
B(i)=S2(i)+S2(i+1);
Total=sum(B);
end
When I try and display "Total", it always ends up with the whole cumulative array instead of just displaying the total itself.
Is there a simple way to display the total without displaying anything else? Thanks in advance.

回答 (1 件)

Daniel Shub
Daniel Shub 2011 年 12 月 12 日
I am not sure what you want Total to be, but you do not need the loop ...
S2 = randn(10,1);
B = S2(1:(end-1))+S2(2:end);
Total = sum(B)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by