Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Alex Yande
Alex Yande am 25 Mär. 2019
Kommentiert: Alex Yande am 25 Mär. 2019
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 Kommentare
madhan ravi
madhan ravi am 25 Mär. 2019
First example is not clear.
Alex Yande
Alex Yande am 25 Mär. 2019
[6 5 4 3 2 1]
[NaN NaN 1 1 NaN NaN]

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 25 Mär. 2019
Bearbeitet: madhan ravi am 25 Mär. 2019
V(find(A==1,1,'first')) % V is your referenced vector
  2 Kommentare
Alex Yande
Alex Yande am 25 Mär. 2019
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 am 25 Mär. 2019
Your second code works wonderful!!
Thanks a lot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by