LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting data to enter into an array

Solved!
Go to solution

Hi,

 

I am trying to enter data into an array using a case statement to select the values of interest.

 

The problem is this, I am running a for loop, and each time it runs it reads a specific value in the existing array (Array 1), using the for loop index as the index for the Array 1. Then I check whether that specific value = a predefined value

 

if it does: the case statement writes the index into a new array (Array 2).

if it does not: the case statement writes a constant - i would like not to have to do this but unfortunately the case loop must have all input terminals connected.

 

Essentially I want Array to to consist only of the values of interest, and no default / constant values.

 

Any ideas?

 

 

0 Kudos
Message 1 of 7
(4,658 Views)

You're expecting an array with 4 elements coming out.  Does it work in the picture you posted?  It seems to me you would only get a 1 element array coming out because there are no shift registers or indexed tunnels.  Anyway, if I understand your problem correctly you're looking for a solution like this. 


 

Message Edited by elset191 on 02-26-2009 08:33 AM
--
Tim Elsey
Certified LabVIEW Architect
Message 2 of 7
(4,645 Views)

You have 2 problems:

  1. As noted, you have no shift register.
  2. You are trying to use the Equal function on floating point values. This will not work. Read up on how floating point numbers are stored in computers. There have been a bijillion posts on this topic in this forum. 
Message 3 of 7
(4,631 Views)

Hi,

 

thank you both for your prompt responses. I've implemented both your suggestions, but am still not getting the loop to work.  I was wondering, if I use the build array function, does it automactically index, or is the second 'input' with the index required. The reason I ask is because when I run the vi, the index within the case loop does increase to 4, however the array that comes out of the for loop doesn't have 4 inputs at different indices i.e. after the for loop completes at index 0 it should return 325, at index 1 it should return  427 up to index 4 at which point it should return 0 as there are only 4 values written to the array.

 

Aaron 

0 Kudos
Message 4 of 7
(4,598 Views)
Solution
Accepted by topic author 1LabViewNewbie1

You are misusing Build Array.  You wire an array into one input and other arrays or values into the others.  See the example I attached.

 

--
Tim Elsey
Certified LabVIEW Architect
Download All
Message 5 of 7
(4,579 Views)
Tim: FYI all of the images you try to embed point to invalid URLs. It seems you are copying the URL that you get when you preview a message. This will not work. The message has to be posted so the image gets uploaded to the correct directory. You can then go back and edit the post to get the correct URL for the image. Alternatively, the image URLs follow a pattern based on the message ID, so you can do it that way, but it's usually easier to just go back and edit the post.
Message Edited by smercurio_fc on 02-27-2009 08:47 AM
Message 6 of 7
(4,577 Views)
Hm.  You're right. thanks.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 7 of 7
(4,572 Views)