LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In mathscript I can only index an array with an actual integer number not a reference from another array

Solved!
Go to solution

Hi

 

Basically I am trying to write a function in Mathscript which works ok in Matlab.

 

I have performed an FFT of a signal which I have used the peak detector VI to find the main peaks

 

 

To find the phase signal I want to reference the location of the peaks to the phase array

 

ie

 

Phase(location(1))

 

I simply get the error -90026. Matrices muct be same size indexes must be integers

 

Is this a bug

0 Kudos
Message 1 of 2
(2,442 Views)
Solution
Accepted by topic author Nadiaf
Hello,

Which version of LabVIEW are you using?  Are you possibly getting two error codes?  Error -90026 is simply that the indices must be real, positive integers.  If you are also getting an error about the size of the matrices being incompatible, try your code in the MathScript Window.  What does
location(1)
return?  A scalar value?  Or an array?

What is the left-hand side of that expression?  That is, are you assigning the output to a variable or a submatrix?
A = Phase(location(1));
or
A(c:d) = Phase(location(1));

What is output when you type
location(1)

Is it an integer value greater than 0?  Or is it a double number?  If you compute the location array in some manner, it may be that due to roundoff error, you don't end up with exactly an integer.  The indexing routines will complain about this.  You can truncate to integers with the int32 function.  Try these suggestions.  If you still have problems, post more of your code so we can reproduce the problem you see.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 2 of 2
(2,436 Views)