フィルターのクリア

Displaying all values from a for loop in one vector

1 回表示 (過去 30 日間)
Rebecca
Rebecca 2013 年 1 月 22 日
Hi everyone. I know people have asked similar questions to this one, but I am a complete novice with MATLAB and have been unable to generalise the answers to my own problem.
I'd like all the answers generated in this loop to be displayed as one vector so that I can export them to Excel for an analysis. This is the loop:
for t=600:600:28800
length(find(sumA<t))
end
It's a very simple loop, but I am stuck! sumA is a vector of values from another loop.
Thanks for any assistance!
Rebecca

採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 22 日
sum(bsxfun(@lt, sumA(:), 600:600:28800))
Or, more generally,
tvals = 600:600:28800;
numT = length(tvals);
L = zeros(numT, 1);
for K = 1 : numT
t = tvals(K);
L(K) = length(find(sumA<t));
end
Then you could write L
  1 件のコメント
Rebecca
Rebecca 2013 年 1 月 22 日
Wow, what a quick response. It worked a charm and I see what you did. Thanks so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by