Extracting specific data points from a matrix
Amo
Hello Forum,
I have a matrix (table9) and I want to extract specific data points such that I also copy values in nearby columns (to table8),
for example, in image attached you can see that data from table9 column 0 are picked and corresponding values from column 1 and 2 are also copied.
I can do it for a 1D wave, picking values in column between 7 and 12
Extract /o SourceWave , DestWave , SourceWave >=7 && SourceWave <=12
Now I have a matrix, I want to get the nearby data as well,
Thank you for your help
There might be a faster way, but this one will work:
make/N=(20,3) w
w[][0] = 6 + enoise(6)
w[][1] = 750 + enoise(50)
w[][2] = 350 + enoise(20)
MatrixOP/O index = col(w,0)
index = index[p] > 7 && index[p] < 12 ? p : NaN
Wavetransform zapNaNs index
Make/O/N=(numpnts(index),3) output = w[index[p]][q]
September 3, 2019 at 10:29 pm - Permalink
And a different way to do, haven't tested speed:
Duplicate/FREE/R=[][0] matrix2d, c0
Extract/INDX/FREE c0, indx, (c0 > lower) && (c0 < upper)
Make/N=(numpnts(indx), DimSize(matrix2d,1))/O $newwname/WAVE=w
w = matrix2d[indx[p]][q]
end
September 4, 2019 at 10:09 am - Permalink
In reply to There might be a faster way,… by ChrLie
@ChrLie That suggestion is very elegant. I used to do this by setting each row as NaN and then use a separate function to split the matrix, zapnans in each and then put it back together. No more!
September 4, 2019 at 12:06 pm - Permalink
... and when you get your hands on IP9 you might want to check the implementation of zapNaNs() in MatrixOP :)
September 4, 2019 at 12:21 pm - Permalink
In reply to There might be a faster way,… by ChrLie
Thanks a lot
September 10, 2019 at 07:51 am - Permalink