LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array search

Solved!
Go to solution

I had 2D array, this array column 1 represent year. Column 2 represent profit.

How to use for loop to search input year then find profit

ex: input    2012

      output  0.4

ironaaron_0-1725872669745.png

 

0 Kudos
Message 1 of 10
(449 Views)

Hi Aaron,

 

convert the 2D array of 2 columns into an array of points, then use the Interpolate1DArray function!

(No FOR loop needed.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(429 Views)

tks a lots interesting method

bcz i had three clusters need searching

two input(Stock number, year) get one output(profit)

now I'm stuck with how to use while loop to get output

ironaaron_0-1725887372397.png

 

0 Kudos
Message 3 of 10
(398 Views)

Hi Aaron,

 


@ironaaron wrote:

bcz i had three clusters need searching


  • Why did your requirement changed from 1st to 2nd post?
  • Why is the "Stock number" input a float when the value in the cluster is an integer?
  • Why do you ask for a WHILE loop when your image only shows a FOR loop?
  • Why do you show just images of code instead of attaching REAL code? (We cannot debug/edit/run images with LabVIEW.)

@ironaaron wrote:

two input(Stock number, year) get one output(profit)

now I'm stuck with how to use while loop to get output


  1. At first a loop will select the correct cluster, based on the stock number.
  2. Then you can apply my previous suggestion on the 2D array inside the cluster…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(392 Views)

wanna searching like 

when input1(stock number):2819, input2(year): 2010, then get output(profit):0.64

never searching for cluster so I'm stuck in this issue now

0 Kudos
Message 5 of 10
(384 Views)

Hi Aaron,

 

you still don't provide an example VI.

I still cannot edit/debug/run images with LabVIEW (see my previous message) and I don't want to recreate your array of clusters "manually"…

 

(Take care of my signature line.)

 

I can also provide images of code:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(363 Views)

this my code tks your patient for wait me asking question

first time suffering cluster, so can't figure out

 

 

0 Kudos
Message 7 of 10
(355 Views)

when stock:8299

           year:2018

still can't recieve my ideal profit(output):2.988

please help me to debu thanks a lot

 

0 Kudos
Message 8 of 10
(335 Views)
Solution
Accepted by ironaaron

Hi Aaron,

 


@ironaaron wrote:

when stock:8299

           year:2018

still can't recieve my ideal profit(output):2.988


Because you don't read the LabVIEW help for the used functions!

 

Please read the help for Interpolate1DArray, it mentions an important requirement for the arrangement of your data! (See the "Note!" at the end of the help article.)

Then re-arrange your data to fit this requirement…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(329 Views)

ignore this crucial note, sincerely my fault

Thank you for patiently answering my questions.

0 Kudos
Message 10 of 10
(323 Views)