LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing array

Solved!
Go to solution

Hi,

In the file below I have a problem that when index is 0,  the first row of the column in the array does not take value as it should like the other rows do. As it is shown in the picture, I got (0+0i)!!!.

test-2.vi Front Panel 23.03.2024 13_52_08.png

 

0 Kudos
Message 1 of 7
(646 Views)
Solution
Accepted by HUSAM2324

Its because you defined indexes and symbol as 2D arrays  with just one column, then when indexing in inner loop you will get "default" values from non-existing elemenths, which are zeroes, this will overwrite elements in 2D array with "unexpected" values.

 

If I understood your needs correctly, then you have to define both arrays as 1D, then use something like that:

snippet.png

Then result should be OK:

Screenshot 2024-03-23 13.00.10.png

In additional, you don't need to use reshape array to create, kjust use initialize array instead, and don't use doubled for indexes, where you need integers.

 

0 Kudos
Message 2 of 7
(619 Views)

I recommend you learn to use Autoindexing Tunnels.  They will simplify your code.  When I did that, I had no issues.

 

It took me way longer to realize what your issue is here than I care to admit.  You are indexing out past the input arrays.  The default values are therefore being indexed out (0 and 0 + 0i).  So your value is being overwritten.  Use Autoindexing tunnels to tell the FOR loops how many times to iterate and this issue goes away.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 3 of 7
(615 Views)

@crossrulz wrote:

I recommend you learn to use Autoindexing Tunnels. 


Yes, for sure, and this can be used on output as well, then may be simplified like that:

snippet2.png

0 Kudos
Message 4 of 7
(606 Views)

Thank you all  

0 Kudos
Message 5 of 7
(589 Views)

@HUSAM2324 wrote:

Hi,

In the file below I have a problem that when index is 0,  the first row of the column in the array does not take value as it should like the other rows do. As it is shown in the picture, I got (0+0i)!!!.

test-2.vi Front Panel 23.03.2024 13_52_08.png

 


When attaching code, make sure that all controls have some typical default values (e.g. as shown in your picture), especially since you seem to have a 2D array with only one column visible (!!!). (Fill your controls, then edit..."make current values default"). As a bonus, you could also fill indicators with the result you want (instead of what you get), so we can verify if our suggestions are actually correct. It is also not clear why your indices are DBL instead of I32. It is also easier to debug if the values are simple.

 

Unlike others here, I don't want to reverse engineer your code, especially since it apparently does not work the way you want.

 

Can we start with a clear description of the problem:

 

  • Why is "indices" a 2D array, how many columns are there, and what do they mean? (Maybe there are two columns, one for each dimension?)
  • Same for the "symbols" array.
  • How big are the various arrays? Are there symmetries? (e.g. does the indexes and symbol array have the same number of rows/elements?)

 

0 Kudos
Message 6 of 7
(544 Views)

Maybe something as follows is what you really want? Wild guess!! (You can change the datatype back to complex, of course).

 

(And no, "reshape array" is not really the intended tool to "initialize an array" (hint!))

 

altenbach_0-1711209318582.png

 

0 Kudos
Message 7 of 7
(539 Views)