LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search and replace elements in a 2D Array

Hello,
 
i have a programming problem in Labview 7.1 under Win XP. I want replace elements in a 2D Array. The code works fine but I want replace elements in the 2D Array (for example all elements between 2 and 5 should replace to zero).
 
Thank you in advance
 
Rene
0 Kudos
Message 1 of 10
(9,505 Views)

Hi Rene,

You said- "all elements between 2 and 5 should replace to zero"

If this is what you  want to achieve, this attached Vi will do the job

Regards

Dev

 

Message 2 of 10
(9,493 Views)
Message 3 of 10
(9,496 Views)
Hello devchander,
 
thank you for your quick response time. But the vi "Replace Array" search only one element for example the element "3" and not all elements with the number three. And then you get the Index. My LV code "Search_and_replace 2D Array.vi" search the element 3 and replace the element for example with zero. But I need a LV code who replaces all elements "3" and "4" to zero.
 
Kind regards,
 
Rene
0 Kudos
Message 4 of 10
(9,481 Views)

Ok Rene,

Look at this attached VI Smiley Wink

Regards

Dev

 

Message 5 of 10
(9,477 Views)
Sometimes, you don't need any loops 😄
 

Note to Devchander:
You can configure the "In Range and Coerce" finction to either exclude or include the limits. This is done by right-clicking on their respecive terminal. Try it! 😉 The terminal will be either a solid or open diamond, depending on configuration.

 

Message Edited by altenbach on 01-11-2006 07:59 AM

Download All
Message 6 of 10
(9,466 Views)

Oh cool!

Thanks for the note, Altenbach!

That is a neat  way to convert 'in range?'  boolean array to(0 ,1) and multiply it with original array to make the elements zero.

Also plz have a look at my previous post to replace 2 individual elements and not all values between them.

Can u suggest a more efficient method?

Regards

Dev

 

 

Message 7 of 10
(9,440 Views)
Dev,
 
"Efficient" is a tricky word. 😮 Note that my "loop free" solution is very simple, but it would be more efficient if I would place 2 FOR loops around the core of the code. If the arrays get very big this will make a difference because we don't need to allocate space for all the intermediary arrays (boolean, 0,1, etc). The only way to tell for sure is to do some profiling and benchmarking. 😉
 
In any case, here's how I might replace a defined set of numbers in a 2D array with a different number. There are many ways to do this. 😉

Message Edited by altenbach on 01-11-2006 09:51 PM

Message 8 of 10
(9,436 Views)

Thanks all for the great support.....

Kind regards,

ReneSmiley Happy

0 Kudos
Message 9 of 10
(9,394 Views)
I am unable to open the "Replace Elements in 2D array.vi" in my version of Labview (7.0). Please send a copy of the block diagram.

Don McCurnin
0 Kudos
Message 10 of 10
(9,360 Views)