フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Find minimum of $n$ first entries, with $1\leq n\leq numel(X)$.

1 回表示 (過去 30 日間)
Bananach
Bananach 2016 年 9 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Given a one-dimensional array $X$, is there a fast way (faster than a for loop) to find $min_{1\leq m\leq n} X(m)$ for all $1\leq n\leq numel(X)$?
  2 件のコメント
Adam
Adam 2016 年 9 月 19 日
Can you give an example of what you are asking for? And preferably in words as semi-symbols are confusing!
Bananach
Bananach 2016 年 9 月 19 日
Given X=[4,3,2,5,7,0] I want Y=[4,3,2,2,2,0]

回答 (2 件)

Mischa Kim
Mischa Kim 2016 年 9 月 19 日
Bananach, use min :
X = rand(1,10)
X =
0.6557 0.0357 0.8491 0.9340 0.6787 0.7577 0.7431 0.3922 0.6555 0.1712
min_X = min(X(1:6)) % find the minumum of the first 6 entries
min_X =
0.0357
  1 件のコメント
Bananach
Bananach 2016 年 9 月 19 日
I should have been more clear: I want a vector that contains the minimum for all possible values of 6 ;) That means, in your example, that I want a vector with 10 elements, with the entries $(min(X(1:j)))_{j=1}^10$

Adam
Adam 2016 年 9 月 19 日
編集済み: Adam 2016 年 9 月 19 日
Y = cummin( X );
will do the job. There are a few in that family of functions that do cumulative analysis on a vector.

この質問は閉じられています。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by