LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get rid of first zero in array

Hey all

 

Want some help with my labview.I m using excel spreadsheet reader to get some numbers from excel sheet to array.I figure out how it works but only problem is it cuttoff deciaml numbers when it comes to array.Anyone know how to figure it out ? 

 

Second problem is i m trying to get rid of first zeros in my array to get it todraw XY graph .I wrote a subvi for that purpose but it  works only the first time then it keep cutting off the rest of the number.If you can help me with this it would be great.

 

Thank you

MNSU

Download All
0 Kudos
Message 1 of 7
(3,184 Views)

You have your data type set to an I32 (integer), so that probably explains why it's cutting off your decimals.  As for your second question about why running it only works the first time, it's because you have an uninitialized shift register.  Wire a 0 to the shift register on the left side of your For loop and it should fix your issue.

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

The reason you are not getting decimal is becasue you are using the integer read spreadsheet. So as soon as it reads the file it converts to integer. 

I've put a simpler way to remove all elements that equal zero by using for loop and conditional indexing terminal. 

See snippet for answers to both. 

0 Kudos
Message 3 of 7
(3,161 Views)

MNSU wrote:

Want some help with my labview.I m using excel spreadsheet reader to get some numbers from excel sheet to array.I figure out how it works but only problem is it cuttoff deciaml numbers when it comes to array.Anyone know how to figure it out ? 


Your VI has nothing to do with excel and cannot read excel files. All you are doing is reading from a comma delimited text file.

 

Your polymorphic selector is set to "interger", giving you I64. Set the polymorphic selector to "Double".

 

It typically helps to keep the code neat. Why did you move the polymorphic selector so far away from the function?

 


@MNSU wrote:

Second problem is i m trying to get rid of first zeros in my array to get it todraw XY graph .I wrote a subvi for that purpose but it  works only the first time then it keep cutting off the rest of the number.If you can help me with this it would be great.


Your code is extremely dangerous, because if the input array is all zero or empty, the VI will run forever and needs to be aborted. Why is the panel maximised to the screen?? Very annoying.

 

In any case, your loop code is extremely convoluted. None of this is necessary. Here are two alternative solutions (there are many more):

 

 

 

(For unusual inputs (empty array, all zero, etc), you might need to tweak for the desired outcome)

 

I still don't understand your point with the XY graph. XY graphs have no problem plotting zeroes. None of the current data structures are even suitable for an xy graph. Please explain.

0 Kudos
Message 4 of 7
(3,147 Views)

rthomas101 wrote:

I've put a simpler way to remove all elements that equal zero by using for loop and conditional indexing terminal. 


He does not want to remove all zeroes, just the zeroes up to the first nonzero element.

0 Kudos
Message 5 of 7
(3,130 Views)

Oh the leading zeros! Right, with you now. 

0 Kudos
Message 6 of 7
(3,122 Views)

Thank you guys.I figure it out. you guys are the best .

0 Kudos
Message 7 of 7
(3,081 Views)