
Assigning part of one wave to another wave

Dolbash
I thought I knew how to do this, but it is not working. I am aiming to take make a new wave who's points are data points from a larger wave.
the code looks approximately like this
Wave2=wave1[leftrange,rightrange].
The compiler keeps throwing the error that it wants there to be a right bracket after where i have substituted the word "left range" ----> wave2=wave1[leftrange], but that will just make wave2 a single-valued wave, which is not what i want. I want it to just be filled with the indicated range from wave1
I'm sorry that I am asking this here as it seems trivial
The right-hand-side doesn't express the point range. That's controlled by the left side. So on the right, p will range from 0 to numpnts(lhs)-1. To get what you want, you would write something like
Wave2=wave1[p+leftrange]
If Wave2 has the right number of points, then rightrange takes care of itself.
But you should also consider
Duplicate/R=[leftrange, rightrange] wave1, wave2
Using Duplicate for this task is generally faster, and more straightforward.
January 25, 2019 at 09:29 am - Permalink
Wave indexing is your friend here. See the following snippet as an example
This assumes your left and right values are both included. The last line contains the crux of the solution. Your question seems to indicate point indexing. Scaled ranges can be accommodated using x2pnt(waveName, x1 ). You also might want to do some preliminary bounds checking if the sub-wave extraction is in a function.
January 25, 2019 at 09:34 am - Permalink
Thank you for your help friends! Solved with duplicate function!
January 25, 2019 at 11:37 am - Permalink