LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mathscript in the vi is showing the error

i'm using ni-6008 to sample voltage and current.

the values obtained are in the form of 1D array.

these values are given to the shift register to have the difference between present value and previous value.

the difference is given as input to the mathscript for the program written as shown in the vi.

array problem.JPG

 

i hope, i'll get the difference between two successive elements in 1D array  and this is fed to mathscript module.

but when i run this vi, it is showing an error as shown

mathscript error.JPG

 

 

how to rectify this error? and also

if we give 1D array as input to mathscript and it is unable to perform comparision operations ( such as greater than, lesser than etc.), then what is the modification shall i do?

please suggest me some solutions

 

0 Kudos
Message 1 of 10
(4,163 Views)

Hi trip,

 

easiest solution would be to replace the mathscript code by "standard" LabVIEW G code!

 

To start you could replace the first 4 lines by InRangeAndCoerce…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,138 Views)

yeah, i've tried that method.

the problem is i'm feeding back the d value for every iteration. i'VE TO update the d value

0 Kudos
Message 3 of 10
(4,108 Views)
I don't think you understand the difference between an array and a scalar. Your script has scalar (single value) variables defined but you are feeding it multiple values as an array. I don't see anywhere your comparison of a current value to a previous one. The image is incomplete. I would also recommend using native LabVIEW functions.
0 Kudos
Message 4 of 10
(4,097 Views)

then please suggest me some way to take the difference of successive values in an array.since sampled voltages are in the form of array

0 Kudos
Message 5 of 10
(4,091 Views)

Hi Trip,

 

to get differences between array elements you can calc like "array[1]-array[0]"!

 

Either use an autoindexing loop or subtract the subarray starting with index 1 from your original array…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(4,070 Views)

can anyone give me the link for the mathscript module syntaxes for the functions? i've tried. but unable to get the required data.

i mean, I NEED ALL THE POSSIBLE SYNTAXES REQUIRED AND ARE PRESENT FOR THE FUNTIONS PRESENT IN MATHSCRIPT MODULE.

 for example, the syntax for 'for' loop is 

for m=1:10 , for m=1:0.1:10, etc.

so i need some pdf that gives all tthe posssible syntaxes for the functions in mathscript module.

 

and i need one more qlarification. is both mathscript and matlab are same?. shall i use all the syntaxes of matlab functions in mathscript. if not, show me some pdfs that tells the correction to do( i mean the proper syntax and format)

 

 

 

0 Kudos
Message 7 of 10
(4,031 Views)

You can use a For loop (to index through your array) and a Shift Register (to hold on to the previous value) to convert an array of data into an array of (data(i) - data(i-1)).  Here I've created an array of 100 random numbers between 0 and 1 ("data") and then used the For loop + Shift Register to compute the Delta array (with an implicit assumption that the number before the first point was 0).  You can do it all in LabVIEW (and should do it all in LabVIEW).

Deltas.png

Bob Schor

0 Kudos
Message 8 of 10
(3,949 Views)

Hi Trip,

 

all tthe posssible syntaxes for the functions in mathscript module.

Have you tried to read the LabVIEW help? The help for the mathscript node?

It explains all the functions and their syntax!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(3,736 Views)

yes. i've tried. there very less explanation is given.

 

0 Kudos
Message 10 of 10
(3,720 Views)