LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare two arrays

Solved!
Go to solution

I have two arrays such as these

 

Array 1                          Array 2

a      1

a      5                                 a

b      2                                 b

c      3                                 f

d      4                                 g

e      5                                 h

f       6

g      7

g      10

h      8

h      9/

 

 

with what i have now i can create an array that lists the matching elements

 

Results:

 

a          1

b          2

f           6

g          7

h          8

 

However, it does not record both sets of a,g, and h, only the first instance. Anyone know how to fix this problem?

Any help is appreciated

 

 

Message 1 of 20
(9,720 Views)

Drat posted to the wrong thread

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 20
(9,709 Views)

OpenG has a search function that returns an array of all occurrences, not just the first one.  That, and a For loop, solves your problem.  If you don't wish to install OpenG, you can make your own function that loops through a 1D array and returns all of the hits.

 

ogsearch.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 20
(9,691 Views)

So if i dont install open g how would i do this?

Thank you

0 Kudos
Message 4 of 20
(9,687 Views)
Solution
Accepted by rmarks12

A FOR loop inside of another FOR loop should do the trick.  Have the outer loop autoindex on the search parameters and the inner loop autoindex on the search array.  On a match, add that item to the list.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 20
(9,679 Views)

Im not sure what your saying, sorry. im pretty new to labview.

0 Kudos
Message 6 of 20
(9,674 Views)

@rmarks12 wrote:

Im not sure what your saying, sorry. im pretty new to labview.


I just added an image to my previous post to show what I mean.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 20
(9,669 Views)

You're the best! Thanks so much for your help!

0 Kudos
Message 8 of 20
(9,660 Views)

@rmarks12 wrote:

im pretty new to labview.


That's okay we were all new at some point.  If you have an question about a function in particular you can open the context help (CTRL + H) and over over a function to learn more.  Also here is some free training if you are interested.

 

NI Learning Center

NI Getting Started

-Hardware Basics

-LabVEW Basics

-DAQ Application Tutorials

 

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

 

With questions on anything else, feel free to do what you are already doing, post here on the forums.

0 Kudos
Message 9 of 20
(9,634 Views)

Hi, is there anyway you can post this except for labview 2013??? I can't open your 2014

0 Kudos
Message 10 of 20
(9,418 Views)