How can i calculate cumulative sum of function?

1 回表示 (過去 30 日間)
Xshermia Xshermia
Xshermia Xshermia 2018 年 8 月 7 日
回答済み: Adam Danz 2018 年 8 月 7 日
R is a function bounds up with "hiz" and "eg". I want to get its cumulative value. I should have 395 R function and calculate cumulative sum of this function.
How can i achieve this problem?
Thx,
eg=linspace(0.01,0.02,395);
for h=1:1:395;
R=@(hiz) 0.015.*(1+hiz.^2/1500)*15000*cos(eg(h));
end

回答 (1 件)

Adam Danz
Adam Danz 2018 年 8 月 7 日
Cumulative sum can be calculated with
cumsum()
However, your h-loop is incorrect. All you're doing within that loop is redefining and overwriting R which is a function handle that is never used.

カテゴリ

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