from two 1D waves to a 2D wave

Hi,
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
jtigor
Try the following.


Function Fasix_Multiply(wA, wB)
	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.
fasix
Thanks,
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?
jtigor
fasix wrote: ...
and in my "Command Window" I have typed

 
simulazione(wPL, w_dist, wAbs)


and the procedure creates "wOut" 2D wave.


is it correct?


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.
s.r.chinn
My previous suggestion is not the best solution because it requires same-sized waves. Try this and see if it works. The result is in a matrix M_product. I used Duplicate to avoid redimensioning the original waves into matrices; /FREE avoids storage clutter of these intermediate matrices.

function outer(wA, wB)
	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