find Maximum values in intervals of time(each 2000 values)

1 回表示 (過去 30 日間)
navid jafari
navid jafari 2022 年 10 月 28 日
コメント済み: Star Strider 2022 年 10 月 30 日
hi
I have a raw of 240001 values. I want to find Maximum values in every 2000 data with its time index.
u= 1 * 240001
t=1 * 240001
max of u[1-2000]? t index ?
max of u[2001-4000] ? t index?
....
thanks for helping me.

採用された回答

Star Strider
Star Strider 2022 年 10 月 28 日
It would help to have the data.
Try something like this —
u = randn(1, 24001);
t = 1:numel(u);
r = 2000;
U = zeros(r,ceil(numel(u)/r));
U(1:numel(u)) = u; % 'U' Matrix
T = zeros(r,ceil(numel(t)/r));
T(1:numel(t)) = t; % 'T' Matrix
[max2000,idx] = max(U);
for k = 1:size(U,2)
t2000(k) = T(idx(k),k);
end
max2000
max2000 = 1×13
3.5442 3.4805 3.3493 3.7120 4.4885 2.9583 2.9585 3.1143 3.7602 3.0909 3.3839 3.2174 1.5598
t2000
t2000 = 1×13
1161 3914 4518 7332 9805 10305 12787 15740 17991 19423 20578 23642 24001
.
  2 件のコメント
navid jafari
navid jafari 2022 年 10 月 30 日
thanks a lot.
It works.
Star Strider
Star Strider 2022 年 10 月 30 日
As always, my pleasure!

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

その他の回答 (1 件)

Florian Bidaud
Florian Bidaud 2022 年 10 月 28 日
Hi,
I would do something like that
for i = 1:(length(u)-1)/2000
maxArray(i) = max(u((i-1)*2000+1:i*2000));
end
You'll have to adjust for the last value to include the 240001st value, your last interval would be [238001:240001] instead of [238001:240000]
  1 件のコメント
navid jafari
navid jafari 2022 年 10 月 30 日
thank you.
but I couldn't use this code for my problem.

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

カテゴリ

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