Extracting rows from 2D matrix

Hello,

I have a 2D matrix "XYwave". I have a time wave "Tseries" corresponding to the number of rows in Xwave, and a columnwave "Y_dp" corresponding to the number of columns. 

Problem:

I have a new timewave "T_new" and I would like to extract the rows and columns from "XYwave"  that only correspond to  T_new, and hence creating a new "XYwave_new". 

***

I have previously being using  matrix averaging function using a T_start and T_stop but on this occasion I do not want to average data. 

***

Thanking you in advance

First you should tell us more about your wave T_new: What is its content? Does this wave have the same number of datapoints or is it a subset of Tseries? What about T_start and T_stop? Also it would help a lot if you could provide an example experiment with some data. 

Anyway, if you know the range of points you want from XYwave you can use Duplicate with the /R flag. In the case that T_new is a subset of Tseries it would turn down to finding the range of points in Tseries which correspond to T_new. The approach depends a bit on how the data looks. 

Hello, 

Thank you for your response.  T_new is the new time wave and it only has 566 rows compared to 2623 rows in the original time wave. An IGOR experiment is attached with the different waves (matrix: WAVEXY, newtimeWave, OrginalTime, Dp_Ywave). 

 

LaMP_extractingfrom2Dmatrix.pxp (299.11 KB)

Thank you for providing the data. I have written a small function which (hopefully) does what you want. In a first step the function finds the rows which correspond to the new time data. For this, I extract the row number where time stamps of the new time wave corresponds to time stamps in the original time wave. I see that the new time stamps sometimes are a bit off from the values in the original time data (i.e., there is no exact match but an in-between value up to several minutes away). I assume you want to have the data from waveXY at exact time values of the new time data (if this is not so important one could just round things off). I use Interp2D in a second step to extract the relevant data from waveXY and put it into a new reduced wave.

Function ExtractTimeRows(origtime, newtime, waveXY)
    Wave origtime, newtime, waveXY

    Variable i, numvals = numpnts(newtime)
    Make/FREE/D/N=(numvals) rowpos = 0
   
    for (i = 0; i < numvals; i += 1)        // find rows where new time matches original time
        FindLevel/P/Q origtime, newtime[i]
        rowpos[i] = V_LevelX
    endfor
   
    Duplicate/O/R=[0,numvals-1] waveXY, new_waveXY
    new_waveXY = Interp2D(waveXY, rowpos[p],q)  // interpolate since position data may be non-integer
End

Execute in you example experiment with

ExtractTimeRows(OrignalTime, newTimeWve, waveXY)

 

Hi Chozo, 

Thank you very much. That appears to work nicely. I just need to check that my new timestamps are correct.

Just another Inquiry. My 2D images are very pixelated (see attached figure)! Is there a function to merge/smooth the colours better from one data point to another? (-to make a prettier figure). I think that this is possible to do with Matlab but not sure if it is possible to do with IGOR. 

 

Thanks again

LaMP matrix plots.jpg (172.38 KB)

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More