LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with double for loop... help!

Hi,
 
I am very stuck, with this problem, i suppose is stupid problem, but i cant see it..
 
I attached the vi. My problem is when I use the double for loop to looking for the values of source array between 2 elements from another array, when the vi 'search 1d array', when the values is out of range, put 0 on the rest of array elements, and i would like remove all the 0, i want the double for loop, show only the index from the values between these elements. I know each time the for loop search the range, and when it doesn't find any value put 0, but i dont know do thats!!
Any help?
 
Regards Fonsi.
 
 

Mensaje editado por Fonsi

0 Kudos
Message 1 of 6
(2,940 Views)
Sorry if I mis-interpreted your request.  I cleaned up the front part some by replacing the two unneeded formula nodes with plain old arithmetic functions and also, if I understood you right, fixed the back end.  All I really did was change the build array to remove the zeros and bundle them into a cluster so each can have variable lengths.
 
If this is not what you wanted please let us know so we can make further modifications...
 
Message 2 of 6
(2,931 Views)

Hi Chaos,

Thanks for the fast reply....

Well, it solves it, but i need 2D array of index of elements, and putting the bundle, i got 1d array of cluster, any way to maintain 2d array with the elements wihtout 0 values??.

I need the output for another calculates...

Regards, Jose.

0 Kudos
Message 3 of 6
(2,924 Views)
Hrph... lemme think.  Well the only thing I can think of offhand would be to change the representation to double and replacing the unneeded zeros with NaNs (not a number).  See example of one possible implementation.  Otherwise I cant think of anything else...
Message 4 of 6
(2,917 Views)

As Chaos said, A 2D array must have the same lenght for all rows. NaN is a good idea and you can just check for its presence in the later code to determine the end of the current trace.

However, you should generate the NaNs at the beginning. Replacing zeroes with NaNs after the calculation can accidentally wipe legitimate zeroes. 😉

I have made a quick modification that also shows some simplifications to your code.

  • Don't use formula nodes for simple add or multiply. LabVIEW is graphical!
  • Same for the big formula. Use wires, no FOR loop needed here! 😄
  • If you want to index element i and element i+1, grow the node and wire i to the first terminal. The second output will be i+1. Isn't that nice? 😄
  • Don't use local variables in a case like this. They break dataflow.
  • Use  In "Range and Coerce" instead of multiple comparisons.

See attached example (LAbVIEW 7.1). Let me know if you have questions. 🙂

Message Edited by altenbach on 09-29-2005 05:24 PM

Message 5 of 6
(2,918 Views)
Hi Chaos,
 
Thanks for the help, it works!. On the next calculates i put if estructure, putting if value is = 0, dont operate.. so maintain the size of array and later when i join all, i can get only the ok values...
 
@Altenbach
 
Thanks for the free lessons ;), you always showing new things to program... thanks a lot, i think i improved a lot from the last 2 year in labview, is true I use easy programation, and i use a lot of for loop and local variable, since i must confirm all the data before, but honestly I do all the program so + or - :).
 
The trick use +1 from the index array is true, never think that !! sad :). I never used 'Range and Coerce', and it is great!. Thanks.
 
I I learn a lot with you, very kind.
0 Kudos
Message 6 of 6
(2,883 Views)