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
(377 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
(357 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
(326 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
(320 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
(312 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
(291 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
(283 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
(263 Views)
Solution
Accepted by topic author 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
(257 Views)

ignore this crucial note, sincerely my fault

Thank you for patiently answering my questions.

0 Kudos
Message 10 of 10
(251 Views)