필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by