How can I have the cumulative sum of the returned values of a function as a vector?

4 ビュー (過去 30 日間)
Sherwin
Sherwin 2016 年 10 月 8 日
編集済み: Blackadder 2016 年 10 月 9 日
I want to have the cumulative sum of the returned values of AB function in a loop...I want the cumulative sum of the returned values of AB function to form a vector every time it is used. Would you please help me?
for i = 1:P
for j = 1:L
for k = 1:(D / 6)
H = AB (Min{j}(k), Max{j}(k));
end
end
end
  2 件のコメント
Marc Jakobi
Marc Jakobi 2016 年 10 月 8 日
You should provide more information. What is P? What is L? what is D? You said AB is a function? What is it supposed to return?
Sherwin
Sherwin 2016 年 10 月 8 日
編集済み: Sherwin 2016 年 10 月 8 日
oh, right. P, L and D are just the number of times the loops should be iterated. They are just the dimensions of the answer matrix and can be replaced by numbers like P=50, L=4 and D=48. AB function returns a random number between Min and Max according to the j and k and Min and Max are provided as inputs of the problem.

サインインしてコメントする。

回答 (1 件)

Blackadder
Blackadder 2016 年 10 月 9 日
You say you expect a "vector" as a return value. Am I to assume that this vector should have 1 column and P*L*(D/6) rows, or vice versa, respectively?
  2 件のコメント
Sherwin
Sherwin 2016 年 10 月 9 日
The problem is that I'm not sure about the dimension of the vector, because I don't know for l=1:4 how many times H should be calculated and then I can have H cumulative values of it. The random returned value if AB function specifies that so it can vary for every iteration.
Blackadder
Blackadder 2016 年 10 月 9 日
編集済み: Blackadder 2016 年 10 月 9 日
So AB can return a vector? Only then would a vector that contains all the H not have the length P*L*(D/6).
And if so, one further question: is there a maximum length to the vector returned by AB?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by