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

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

DrilonShabani
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

Like this:

Success!
Luc

View solution in original post

15 REPLIES 15

Really?

Like this:

Success!
Luc

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.

?


"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

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

Sorry for my amateur question.  😕

What is your criterion for 'Not applicable'.?

Luc

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?

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

MJG
18-Opal
18-Opal
(To:MJG)

Here's another approach:

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.

Werner_E
24-Ruby IV
(To:MJG)

You may also use

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

so you would not need to calculate B first.

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:

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

Capture.PNG

Announcements