08-16-2007 09:20 PM
08-16-2007 11:16 PM
Hi Chen,
Attached are two VIs, "Diff.vi" implements your example exactly, it outputs the minimum value of the subtraction and the corresponding indexes.
If you want to locate two values from A with the least difference between them, Diff_abs.VI is a little more efficient.
Cheers!
08-16-2007 11:26 PM
08-16-2007 11:57 PM - edited 08-16-2007 11:57 PM
@chenli868 wrote:
for (i=0;i++;i<SIZE)for (j=0;j++;j<SIZE)b[ i ][ j ]= a[ i ] - a[ j ];
A literal translation would be the following:
Message Edited by altenbach on 08-16-2007 09:58 PM
08-17-2007 12:26 AM - edited 08-17-2007 12:26 AM
Hi chen,
Your welcome! - but be warned: Diff.vi has a bug!
Diff_abs.vi is OK, but go with Altenbach's code if you really want the N by N array.
(I tested Diff_abs.vi then partially gutted-it to make Diff.vi which wasn't tested -)
Cheers!
Message Edited by tbd on 08-17-2007 12:29 AM