フィルターのクリア

calculating max value of each interval in a data and apply loop for each interval.

14 ビュー (過去 30 日間)
sud
sud 2018 年 5 月 14 日
編集済み: Aditya Salveru 2018 年 5 月 15 日
hello. i have a column of 18200 values. i want to divide it into interval of 10 elements each. and then calculate the max value of each interval. but, when i want to calculate the max value of 2nd interval, i want to consider all values from the previous interval. and then calculate the max value of 1st 20 elements.i want to do the same to the rest of the intervals. please help me how can i apply such a loop? thank u.

採用された回答

Aditya Salveru
Aditya Salveru 2018 年 5 月 14 日
編集済み: Aditya Salveru 2018 年 5 月 15 日
Hi sud,
You can do this by by finding the max of 1-10,1-20,1-30....elements. The code for the same is as follows:
k=randi(500,18200,1);
n=1:10:length(k); % n becomes [1,10,20,...18200]
maximum=[];
for i=1:length(n)
maximum(i)=max(k(1:n(i))); % i'th element of maximum would be the max upto i'th interval of k.
end
maximum
I have taken array k to be 18200 random values you can change it as you want.
Hope this helps.
  3 件のコメント
sud
sud 2018 年 5 月 14 日
also i want i to go from 1 to 4000 and not the whole length of k
sud
sud 2018 年 5 月 14 日
thanks a lot. its done.

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

その他の回答 (1 件)

KSSV
KSSV 2018 年 5 月 14 日
YOu can use reshape to divide into intervals..and then use max. Read about reshape and max
  1 件のコメント
sud
sud 2018 年 5 月 14 日
thanks but reshape is not really useful for what i want to do.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by