05-19-2009 04:26 AM - edited 05-19-2009 04:27 AM
hey there,
I'm using Labview to program a colour sensor.
In Labview some computations have to be made to calculate the colour detected closest to the calibration data.
Within a MathScript Node the external data acquired should be processed to find the minimum of 3 values - all of them having a data type of "DBL", so doubles.
No matter if I use the min(vector) function or then do the comparison through if-loops (as there are only 3 variables) like x > y, I always get the same error message: "This function is not defined for non-matrix data types."
Although, the syntax in MathScript should be similar to Matlab.
Does anybody know how to circumvent this problem?
Thank you in advance!
cheers, matthia
configuration: LabVIEW 8.5.1 on Windows XP
05-19-2009 06:58 AM
hey, it's me again..
I am trying to provide some more information on my problem with calling the min() function with variables.
the lines within the mathscript node look like the following (signal and count are inputs to this node):
if count == 0
D_r = signal
end
if count == 1
D_g = signal
end
if count ==2
D_b = signal
end
vector = [D_r D_g D_b];
colour = min(vector);
see also the VI attached at the bottom.
but this last line will be answered by the already mentioned error message..
it seems like the mathscript node cannot treat variables..
still, I hope somebody has the solution to this problem ready..!
greets,
matthias
05-20-2009 09:59 AM
Hi mtruess,
try to instantiate your variables outside of the IF statement instead of using the variable for the first time inside the if statement...
hope this will solve your problem.
cheggers
05-26-2009 11:42 AM
Hi mtruess,
were you able to solve the problem?
greetings,
cheggers
05-26-2009 12:43 PM
Hi Matthias,
I'm not able to look at your vi right now, but the given code fragment can be done in LabView using a "Replace array element" function: wire the (old) vector to the input, signal to element, count to index input. At the output you get the "vector" with replaced element which you can wire to the "array min/max" function. Just two primitive functions.
If all the other mathscript code is of same quality you should code it all in LabView...