Compare Two Matrices
bgallarda
closeness
. This code could easily be modified to compare two 1D, 3D, etc. waves as well. The function creates and displays a matrix the same size as the input matrices with ones and zeros as values.Function matrixcomp(w1,w2,closeness)
WAVE w1
WAVE w2
Variable closeness
variable a = dimsize(w1,0)
variable b = dimsize(w1,1)
variable c = dimsize(w2,0)
variable d = dimsize(w2,1)
if(a != c || b != d)
abort "Same size matrices please!"
endif
redimension/N=(a*b) w1
redimension/N=(a*b) w2
variable i=0
make/O/N=(a*b) CompMat
Do
if(abs(w1[i]-w2[i]) <= closeness)
CompMat[i] = 1
else
CompMat[i] = 0
endif
i+=1
While(i<(a*b))
redimension/N=(a,b) w1
redimension/N=(c,d) w2
redimension/N=(a,b) CompMat
display; appendimage CompMat
End
WAVE w1
WAVE w2
Variable closeness
variable a = dimsize(w1,0)
variable b = dimsize(w1,1)
variable c = dimsize(w2,0)
variable d = dimsize(w2,1)
if(a != c || b != d)
abort "Same size matrices please!"
endif
redimension/N=(a*b) w1
redimension/N=(a*b) w2
variable i=0
make/O/N=(a*b) CompMat
Do
if(abs(w1[i]-w2[i]) <= closeness)
CompMat[i] = 1
else
CompMat[i] = 0
endif
i+=1
While(i<(a*b))
redimension/N=(a,b) w1
redimension/N=(c,d) w2
redimension/N=(a,b) CompMat
display; appendimage CompMat
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More