from two 1D waves to a 2D wave
fasix
I have 2 columns of data (A and B), I would like to create a matrix (M) which the first column there is A multiplied by the first value of B, the second column of B is A multiplied by the second value of B, and so on.
over multiplication, I wish it was possible to apply other functions (exponential and others)
how can you do?
thanks
Wave wA
Wave wB
Variable nPointsInA
Variable nPointsInB
Variable nIndex
nPointsInA = DimSize(wA, 0)
nPointsInB = DimSize(wB, 0)
Make/O/N=(nPointsInA, nPointsInB) wOut
for(nIndex = 0; nIndex < nPointsInB; nIndex += 1)
wOut[][nIndex] = wA[p] * wB[nIndex]
endfor
End
Edit the contents of the for/endfor loop to do something other than multiplication.
March 17, 2015 at 11:20 am - Permalink
I have created the following procedure:
#pragma rtGlobals=1 // Use modern global access method.
Function simulazione(wA, wB , wC)
Wave wA
Wave wB
Wave wC
Variable nPointsInA
Variable nPointsInB
Variable nIndex
nPointsInA = DimSize(wA, 0)
nPointsInB = DimSize(wB, 0)
Make/O/N=(nPointsInA, nPointsInB) wOut
for(nIndex = 0; nIndex < nPointsInB; nIndex += 1)
wOut[][nIndex] = wA[p] * exp (- wC[p] * 10 * wB[nIndex])
endfor
End
and I have complied it.
and in my "Command Window" I have typed
simulazione(wPL, w_dist, wAbs)
and the procedure creates "wOut" 2D wave.
is it correct?
March 18, 2015 at 04:29 am - Permalink
Yes.
Each column in wOut shows the result of the calculation on wPL and w_dist with a constant value from wAbs.
So the first column in wOut is
wOut[][0] = wA[p] * exp (- wC[p] * 10 * wB[0])
Is this giving you expected results?
The "p" is an implicit function in igor used on the right side in an assignment statement to refer to the first index (rows) of a wave on the left side of the statement. If that is a bit confusing you might look up wave indexing in the online help.
March 18, 2015 at 06:34 am - Permalink
March 18, 2015 at 07:57 am - Permalink
wave wA, wB
duplicate/O/FREE wA, wAF
duplicate/O/FREE wB, wBF
Redimension /N=(numpnts(wAF),1) wAF
Redimension /N=(1, numpnts(wBF)) wBF
MatrixMultiply wAF, wBF // result is in M_product
end
March 19, 2015 at 06:52 am - Permalink