フィルターのクリア

How can i assign a value for this type of datas?

2 ビュー (過去 30 日間)
Alex Yande
Alex Yande 2019 年 3 月 25 日
コメント済み: Alex Yande 2019 年 3 月 25 日
Hi,
I want to assign a value for a given vector with using a one rule. Assigned value will be named as x.
My reference vector is:
[6 5 4 3 2 1]
For ex., given vector is symbolized as A:
A=[NaN NaN 1 1 NaN NaN]
x should be equal to 4.
or if A equals to:
A=[1 1 1 1 1 1]
x=6
Finally, a last example:
A=[NaN NaN NaN 1 1 1]
x=3
Briefly, x value should be equal to leftmost 1's reflection in referance vector.
How can i perform this control?
Thx!
  2 件のコメント
madhan ravi
madhan ravi 2019 年 3 月 25 日
First example is not clear.
Alex Yande
Alex Yande 2019 年 3 月 25 日
[6 5 4 3 2 1]
[NaN NaN 1 1 NaN NaN]

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

採用された回答

madhan ravi
madhan ravi 2019 年 3 月 25 日
編集済み: madhan ravi 2019 年 3 月 25 日
V(find(A==1,1,'first')) % V is your referenced vector
  2 件のコメント
Alex Yande
Alex Yande 2019 年 3 月 25 日
V(find(A,1,'first')) % V is your referenced vector
It works, but give me uncorrect result.
A=[NaN 1 1 1 NaN NaN]
V=[6 5 4 3 2 1]
V(find(A,1,'first'))
ans =
6
It must be equal to 5.
Alex Yande
Alex Yande 2019 年 3 月 25 日
Your second code works wonderful!!
Thanks a lot.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by