I want to re-scale the "Scaled Dimensional index" of a two dimensional wave. For this I need to know the 'Scaled Dimension Index' of particular data point from it's row index and column index.
Here is some example code to get you started for your particular needs:
function foo()// make a test wave Make/O/N=(13, 9) wave0 setscale/Ix, -0.6, 0.6,"" wave0 setscale/Iy, -4.0, 4.0,"" wave0
wave0 = Gauss(x, 0, 0.2, y, 0, 2) end
function bar(rowIndex, columnIndex)// test the function below variable rowIndex, columnIndex WAVE wave0 Wave wOut = ScaledDimIndex(wave0,rowIndex, columnIndex) print wOut end
function/WAVE ScaledDimIndex( InputWave, rowIndex, columnIndex) // returns the x and y scaled dimension indices as a two-element wave wave InputWave variable rowIndex, columnIndex make/O/N=2 wOut variable xx = DimOffset(InputWave,0)+DimDelta(InputWave,0)*rowIndex variable yy = DimOffset(InputWave,1)+DimDelta(inputWave,1)*columnIndex
wOut = { xx, yy } return wOut end
When testing this, you should see:
•bar(1, 1)
wOut[0]= {-0.5,-3}
as the {x, y} values for point indices [1][1].
Note the core functions DimOffset and DimDelta for use with multidimensional waves.
for each dimension that you need the scaled position (0 and 1 for rows and columns respectively)
I would normally suggest using SetScale to "re-scale" the dimensions of a wave, but you don't need to know its current settings to do that, so I'm not sure that's quite what you're asking for.
@s.r.chinn and @ikonen - Thank you very much! You have given the exact answer, I was looking for. Part of my problem is now solved. For quick checks, I am using DimOffset and DimDelta. But I am writing a macro to process several waves, where chinn's elaboration is very helpful. Thanks!!!
I would normally suggest using SetScale to "re-scale" the dimensions of a wave, but you don't need to know its current settings to do that, so I'm not sure that's quite what you're asking for.
I need to know the scaled dimension value first to determine the re-scale value. I am writing a macro, and I need to call it.
Make/O/N=(13, 9) wave0
setscale/I x, -0.6, 0.6,"" wave0
setscale/I y, -4.0, 4.0,"" wave0
wave0 = Gauss(x, 0, 0.2, y, 0, 2)
end
function bar(rowIndex, columnIndex) // test the function below
variable rowIndex, columnIndex
WAVE wave0
Wave wOut = ScaledDimIndex(wave0,rowIndex, columnIndex)
print wOut
end
function/WAVE ScaledDimIndex( InputWave, rowIndex, columnIndex)
// returns the x and y scaled dimension indices as a two-element wave
wave InputWave
variable rowIndex, columnIndex
make/O/N=2 wOut
variable xx = DimOffset(InputWave,0)+DimDelta(InputWave,0)*rowIndex
variable yy = DimOffset(InputWave,1)+DimDelta(inputWave,1)*columnIndex
wOut = { xx, yy }
return wOut
end
When testing this, you should see:
wOut[0]= {-0.5,-3}
as the {x, y} values for point indices [1][1].
Note the core functions DimOffset and DimDelta for use with multidimensional waves.
December 12, 2012 at 06:34 am - Permalink
for each dimension that you need the scaled position (0 and 1 for rows and columns respectively)
I would normally suggest using SetScale to "re-scale" the dimensions of a wave, but you don't need to know its current settings to do that, so I'm not sure that's quite what you're asking for.
December 12, 2012 at 06:39 am - Permalink
December 12, 2012 at 07:13 am - Permalink
I need to know the scaled dimension value first to determine the re-scale value. I am writing a macro, and I need to call it.
December 12, 2012 at 08:40 am - Permalink