cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

8-Gravel

## How to create a vector B that has only the values of vector A that are lower than a value?

If i have a vector A=(0.45, 1.78, 0.82, 0.95, 1.99,  1.12, 0.77), how to create a vector B that contains only B=(0.45, 0.82,  0.95, 0.77); only values that are lower than 1. The other values may be 0 for example.

1 ACCEPTED SOLUTION

Accepted Solutions
23-Emerald II
(To:DrilonShabani)

Like this:

Success!
Luc

15 REPLIES 15
23-Emerald I
(To:DrilonShabani)

Really?

23-Emerald II
(To:DrilonShabani)

Like this:

Success!
Luc

8-Gravel
(To:LucMeekes)

But is number 3 in this case considered as the second number or third number of the matrix? Because the output of the matrix must be with the same number of elements. I need them to be connected with some other vectors.

23-Emerald II
(To:DrilonShabani)

?

"3" is the second number in the vector.

Your example shows a vector B that is shorter than A. That's what my  (and Fred's) function provides.

Please specify more carefully and exactly what you want.

Luc

8-Gravel
(To:LucMeekes)

Is it possible that i get a text instead of a number?  For example: "Not applicable"

Sorry for my amateur question.  😕

23-Emerald II
(To:DrilonShabani)

What is your criterion for 'Not applicable'.?

Luc

8-Gravel
(To:LucMeekes)

If any value is bigger than 1 in vector A, i want the result on vector B for that number to be "Not Applicable"

Like this?

8-Gravel
(To:MJG)

Exactly . Thank you very much to you,  LucMeekes and Fred.

18-Opal
(To:MJG)

Here's another approach:

8-Gravel
(To:MJG)

I have one more problem. Lets say i have vector B that you created and vector C=(4,  9, 19, 2, 11, 19, 55). I need to create vector D that is: if the value in B is NaN,  also D to be NaN,  if the value in B is number(lower than 1 in this case),  the result in D must be the value from C.

24-Ruby V
(To:MJG)

You may also use

D:=IF(A<1, C,NaN) (vectorized, of course)

so you would not need to calculate B first.

24-Ruby V
(To:DrilonShabani)
 Drilon Shabani wrote: If i have a vector A=(0.45, 1.78, 0.82, 0.95, 1.99,  1.12, 0.77), how to create a vector B that contains only B=(0.45, 0.82,  0.95, 0.77); only values that are lower than 1. The other values may be 0 for example.

If 0 is OK (instead of NaN or "n.a.") you may simply use this vectorized statement:

6-Contributor
(To:DrilonShabani)

In Prime . . . You could just use the lookup function...... like this . . . much simpler

Announcements