Making a variable size 1D or 2D wave

Hi All, 

Quick question. I have a 1D wave - wave1. I want to select certain values from wave1 that are smaller than 50 and store them in a new 1D wave-wave2. 

Now, I don't know how large wave2 will be since it depends on how many values in wave1 are smaller than 50. 

So I want to make wave2 such that its row size is flexible. Kindly advise how to do this. 

What I'm doing right now is creating wave2 the same size as wave1, storing values, and deleting all bottom rows that are nans. However, this doesn't feel elegant as a code. 

Also, instead of running it in a for loop, I am wondering if there is one-liner conditional statement possible that can accomplish this task.. something that may look smoother like-- wave1[i] < 50 ? wave1[i]=wave2[] : wave1



There is the built in 'Extract' function that does just this See:

DisplayHelpTopic "Extract"


Extract wave0, wave1, (wave0 < 50)

'Wave1' will be created containing only the values smaller than 50 from 'wave0' in your test case.

Wow, this is awesome! I wasn't aware of this function.. 

Spent nonzero amount of time in life running for loops instead of this beautiful one-liner. Never going back! 

I'm assuming it would work for any condition i.e. <, >, !=, == etc. 

Thanks cpr!