Skip to main content
1-Visitor
October 18, 2016
Solved

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

  • October 18, 2016
  • 15 replies
  • 4877 views

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.

Best answer by LucMeekes

Like this:

Success!
Luc

15 replies

23-Emerald I
October 18, 2016

Really?

LucMeekes23-Emerald IVAnswer
23-Emerald IV
October 18, 2016

Like this:

Success!
Luc

1-Visitor
October 18, 2016

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 IV
October 18, 2016

?


"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

25-Diamond I
October 18, 2016

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:

12-Amethyst
October 19, 2016

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

Capture.PNG