Sum through an array until a value is reached, then continue
3 ビュー (過去 30 日間)
古いコメントを表示
Assume you have 2 arrays x = linspace(0.001,0.005,1000); y = linspace(0,1,1000);
I want to start at the beginning of x, and sum consecutive columns until the sum = 0.1, then take the average of y across that range.... then continue doing this until the end of x
6 件のコメント
Bruno Luong
2018 年 11 月 2 日
編集済み: Bruno Luong
2018 年 11 月 2 日
"With the values given, the first 100 columns would sum to 0.1"
No body know where the 100 comes from. Anyone is guessing and people just wastes theirs times for you.
Not give example is better than give one that doesn't make sense.
採用された回答
その他の回答 (2 件)
Guillaume
2018 年 11 月 2 日
sumx = cumsum(x);
meanybelowthreshold = mean(y(sumx <= 0.1));
meanyabovethreshold = mean(y(sumx > 0.1));
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!