LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to find indices and values of nonzero elements?

hi everyone,

 

in matlab there is a special function called find(x) that find indices and values of nonzero elements, how can i do the same thing in Labview, anyone have ideas or ever did this?

 

thanks!

0 Kudos
Message 1 of 18
(6,844 Views)

Non-zero element means any number or a single value you want to find? In Array you have search 1D array which does similar thing what you want. Gives you the index where the value is (x)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 18
(6,838 Views)

As Anand writes, Search 1D Array is definetly an option. But this works out for integer, boolean or strings properly, but not for floating point numbers directly.

 

But i doubt, that find(x) in MatLab can handle a float x properly without pre-analysis....

 

So if working with floats, you should do something like this:

FindFirstFloatRange.PNG

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 18
(6,829 Views)

If you have LabVIEW 2012 you can use the Conditional Tunnel Mode to recreate the basic find(X) functionality. If yu don't have 2012 you will need to create the logic that builds the 2 arrays on the output of the For loop.

 

Array of non-zero values and index

 

Here is another version my coffee induced creativity came up with:

 

Matlab - Find(X in LabVIEW) Rev 2

David C
Download All
0 Kudos
Message 4 of 18
(6,827 Views)

Or you could even do it this way:

 

Search for Value.png

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 5 of 18
(6,813 Views)

I need to post to the forums more often. After my earlier post I received the following personal message via the NI Discussion Forums:

 

"God bless you I am Miss. Veronica the director of bill furthermore at the foreign remittance department of SG-SSB Bank Limited, board of administrator en route for my bank mandated me to look for least known relative of our late client he deposited in our bank sum of fourteen million five hundred thousand dollars, send a mail to my private email address (loveveronica17@gmail.com  or  loveveronica17@gmail.com) so that I can explain more details to you, please acknowledge my mail, Best regards, Miss.Veronica"

David C
0 Kudos
Message 6 of 18
(6,808 Views)

Strange PM.... would report that to moderators.

 

Regarding the posted suggestions:

Please don't post code/images of code where you compare floating point numbers with direct equal or not equal functions. In most cases, it works, but not in every case (2!=2 might return true for instance)!

 

thanks,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 18
(6,804 Views)

@DavidCorney wrote:

I need to post to the forums more often. After my earlier post I received the following personal message via the NI Discussion Forums:

 

"God bless you I am Miss. Veronica the director of bill furthermore at the foreign remittance department of SG-SSB Bank Limited, board of administrator en route for my bank mandated me to look for least known relative of our late client he deposited in our bank sum of fourteen million five hundred thousand dollars, send a mail to my private email address (loveveronica17@gmail.com  or  loveveronica17@gmail.com) so that I can explain more details to you, please acknowledge my mail, Best regards, Miss.Veronica"


I got the same PM. Cheers 😄

-----

The best solution is the one you find it by yourself
0 Kudos
Message 8 of 18
(6,799 Views)

@Norbert_B wrote:

Strange PM.... would report that to moderators.

 

Regarding the posted suggestions:

Please don't post code/images of code where you compare floating point numbers with direct equal or not equal functions. In most cases, it works, but not in every case (2!=2 might return true for instance)!

 

thanks,

Norbert


Maybe I am being dense, Norbet, but you lost me when it comes to comparing a floating point numbers.

 

In my mind a number is zero, or not zero, irrespective of data type and digits of precision. Why would the equal and not equal to zero functions fail with floating point numbers? If you are suggesting they should never be used with floating point numbers, that is going to confuse the heck out of a lot of LabVIEW users, especially the less numerically sophisticated (me).

 

Can you explain your logic in simpler terms for me? Thanks. 

David C
0 Kudos
Message 9 of 18
(6,790 Views)

This

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 18
(6,769 Views)