取消
显示结果 
搜索替代 
您的意思是: 

2D array search

已解决!
转到解答

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 项奖励
1 条消息(共 10 条)
1,521 次查看

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
2 条消息(共 10 条)
1,501 次查看

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 项奖励
3 条消息(共 10 条)
1,470 次查看

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 项奖励
4 条消息(共 10 条)
1,464 次查看

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 项奖励
5 条消息(共 10 条)
1,456 次查看

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
6 条消息(共 10 条)
1,435 次查看

this my code tks your patient for wait me asking question

first time suffering cluster, so can't figure out

 

 

0 项奖励
7 条消息(共 10 条)
1,427 次查看

when stock:8299

           year:2018

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

please help me to debu thanks a lot

 

0 项奖励
8 条消息(共 10 条)
1,407 次查看
解答
已被主题作者 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 项奖励
9 条消息(共 10 条)
1,401 次查看

ignore this crucial note, sincerely my fault

Thank you for patiently answering my questions.

0 项奖励
10 条消息(共 10 条)
1,395 次查看