NI製品ディスカッション

キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

配列の最大最小

解決済み
解決策を見る

配列の最大最小を使って,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 件の賞賛
メッセージ1/5
1,007件の閲覧回数

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

 

LucianM_0-1618150941510.png

 

Lucian
CLA
0 件の賞賛
メッセージ2/5
992件の閲覧回数

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 件の賞賛
メッセージ3/5
971件の閲覧回数
解決策
トピック作成者Yutakaが受理

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

0 件の賞賛
メッセージ4/5
966件の閲覧回数

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 LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 件の賞賛
メッセージ5/5
954件の閲覧回数