LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping the Output of Zero Values

I have been trying to find the easiest way to stop the output of values that are zero. I know there must be a an easy way, but I can't figure it out, maybe because I have never used labview before. Any help would be appreciated: see the attached.

 

The issue is with the primenumberlist. It outputs zeros and I'm trying to stop the output. I have included the other program so you can run the subroutine and see what I mean.

Download All
0 Kudos
Message 1 of 7
(2,818 Views)

Why are you creating a 2-D array to write data to a spreadsheet file when it seems like your end result is to just be a list which would be 1-dimensional?

 

Inside your For Loop, put a case structure.  If the value is prime, then you can use build array to put the value at the end of the 1-D array.  If it is not prime, then you just pass the 1-D array through.

 

On your For Loop, you initialize an empty 1-D array, and use a shift register to maintain its value from iteration to iteration.  Now the only values that are put into the 1-D array are primes, and zeroes do not get built into the array.

 

Message 2 of 7
(2,805 Views)

Thank you. I think I finally understand the function of the shift register. It's basically a "dummy" variable that allows the loop to go through and not terminate without doing anything to the loop.

 

One more thing, the output right now changed into a row format. How do I change it into a column? I tried used the transpose array feature, but that's only for 2D. Is there something that will transpose the 1D array?

0 Kudos
Message 3 of 7
(2,797 Views)

@Excelsius wrote:

Thank you. I think I finally understand the function of the shift register. It's basically a "dummy" variable that allows the loop to go through and not terminate without doing anything to the loop.

 

One more thing, the output right now changed into a row format. How do I change it into a column? I tried used the transpose array feature, but that's only for 2D. Is there something that will transpose the 1D array?


 

The shift register is sort of like a "dummy variable".  It would be like a statement x=x+1 in a loop in a text based language where the variable X stores a value between loop iterations just like a shift register stores a value in a wire between loop iterations.  I don't quite understand or agree with you 2nd part about "not terminate without doing anything to the loop."

 

If you aren't familiar with shift registers, then make sure you take the LabVIEW tutorials.

LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 

There are a few different ways to do the columns vs. rows on your data.  But I think the easiest would be to build your 1-D array into a 2-D after the For Loop and before putting into the 2-D array input of the Write to Spreadsheet File.  You'll have to experiment to see whether you need to connect a True or False constant to the Transpose Array? input of the Write to SS File VI.

 

 

 

0 Kudos
Message 4 of 7
(2,791 Views)

Could you please elaborate on the conversion? I looked here: http://forums.ni.com/t5/LabVIEW/1d-array-into-2d-array/td-p/832823 but still did not see how to convert a 1D into 2D array.

0 Kudos
Message 5 of 7
(2,785 Views)

The same way you were doing in your original VI where you were building a scalar into a 1-D array.

 

You just use a Build array function with one input (the 1-D array) which then builds it into a the single output (which then becomes the 2-D array.)

 

Message 6 of 7
(2,782 Views)

Now I see. Sometimes I'm overthinking this. Need a different approach.

0 Kudos
Message 7 of 7
(2,775 Views)