NI製品ディスカッション

cancel
Showing results for 
Search instead for 
Did you mean: 

配列の最大最小

Solved!
Go to solution

配列の最大最小を使って,2次元配列の各列ごとの最大値を求めたいと思っています。ヘルプによると,2次元配列の場合は,出力が1次元配列になるはずですが,スカラーになってしまいます。結果は配列全体の中から最大値が出力されてしまいます。どうしたら,配列で最大値が出力できるでしょうか?

https://zone.ni.com/reference/ja-XX/help/371361R-0112/glang/array_max_and_min/#details

Yutaka_0-1618148753471.png

Yutaka_1-1618148814066.png

0 Kudos
Message 1 of 5
(237 Views)

Use Index Array in a loop to index each column and call Array Max & Min:

 

LucianM_0-1618150941510.png

 

Lucian
CLA
0 Kudos
Message 2 of 5
(222 Views)

Hi Lucian

 

Thank you very much for your comment! I tried your method and worked fine. I misunderstood the help document. If we input 2d array, the function outputs 1d array of index not 1d array of maximum value.

Yutaka_0-1618152960632.png

 

0 Kudos
Message 3 of 5
(201 Views)
Solution
Accepted by topic author Yutaka

This vi returns max and min values of each column of 2d array as 1d array. 

0 Kudos
Message 4 of 5
(196 Views)

Hi Yutaka,

 

this will do the same as your VI:

No need to use "matrix" functions when you want to handle simple (2D) arrays! (Matrix functions should only be used for linear algebra problems!)

No need to check the array size when you use autoindexing FOR loops…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 5 of 5
(184 Views)