I'm trying to create a function that will take two sets of waves, compare them, and create a third wave based on given parameters.
wave1 is mass data, and has values for every data point. Wave2 is also mass data, but some data points are zero. I need to compare Wave1 and Wave2, and for the data points where wave2 has a non-zero value, the third wave needs to be the difference of Wave1 minus Wave2. so the third wave will have the number of data points that match the number of non-zero data points in wave2.
If I understand correctly, this function will do what you want. It's basic and doesn't check the waves are the same length for example.
Function CompareWaves(w1, w2, result)
Wave w1,w2
String result
Make/O/N=(numpnts(w1)) $result
Wave resultW = $result
resultW[] = w1[p] - w2[p]
resultW[] = (w2[p] == 0) ? resultW[p] : NaN
WaveTransform zapnans resultW
End
So, if your waves are called foo and bar, and you want the result to be called diff. Call the function using CompareWaves(foo,bar,"diff")
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.