LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix -> Average, Max

Solved!
Go to solution

お世話になります。

 

何層かある表から、同じ場所の値の平均値と最大値を添付のように求めたいです。

作り方を教えて下さい。

添付は質問用に3層にしています。

実際は縦横サイズも大きくなり、100層程度になります。

よろしくお願いします。

LabVIEW 2018 32bit

----------------

I would like to find the average and maximum values ​​for the same location in a multi-layer table, as in the attached file. Please let me know how to create it.

For the purpose of the question, the attached file has three layers.

In reality, row and collum will be larger, and I think the number of layers will be around 100.

Thank you in advance.

 

maarai_0-1751637873847.png

 

 

0 Kudos
Message 1 of 8
(273 Views)

VI はこちらです。

0 Kudos
Message 2 of 8
(269 Views)

Yamaeda_0-1751643046315.png

 

Since you want to extract all pages and take the average of that, i go through all matrix positions and extract the "page column".

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 8
(228 Views)

First comment -- LabVIEW makes a significant distinction between "Array" (which can have non-negative number of dimensions, e.g. 1, 2, 3, .. 17) and "Matrix", which is a mathematical 2-D structure associated with Linear Algebra and Vector Spaces.  Your question involves Arrays.

 

Look at the Array Palette.  Do you see "Index Array", which can produce a copy of an Array with the indices you specify.  If we use the common convention for a 3-D array that the first dimension is X, the second Y, and the third Z, then if you wire a 3D Array into "Index Array",

 

When you get above two dimensions, visualizing the (say 3-dimension) Array gets a little tricky, as you can only "see" a 2D "window" (which you can move around, but figuring out how to "index" the Array can be tricky).  What I find helpful (and sometimes "head-scratching") is to create small "dummy" Arrays where the Array contents are the Array "Address".  Thus if I have a 3 x 3 x 10 Array (like your multiple 3 x 3 Arrays), and I want to treat them as "10 3 x 3 Arrays", how do I "visualize" each 3 x 3 "slice"?

 

     The simplest, and easiest to understand, answer is to write a little VI that takes your 3 x 3 x 10 Array and "Z", the index (from 0 to 9) of the "plane" you want to show, and simply wire that to an Array Indicator.  The much harder thing to figure out is to wire it directly to a 3-D Array Indicator -- with only two indices to manipulate, you'll go nuts trying to cycle through the 3 x 3 "planes".  Do the experiment yourself, then simply write an "Extract Z Plane" sub-VI where you input 3 x 3 x 10 and the desired Z, and it spits out the correxponding X-Y.

 

     This is left as an Exercise for the Reader.  Trust me, yiou'll learn from it (i certainly did when I tried to do this myself to help you figure out how to do this ...

 

Bob Schor

0 Kudos
Message 4 of 8
(214 Views)

@ma.arai wrote:

 

I would like to find the average and maximum values ​​for the same location in a multi-layer table, as in the attached file. Please let me know how to create it.

For the purpose of the question, the attached file has three layers.

In reality, row and collum will be larger, and I think the number of layers will be around 100.

Thank you in advance.


So for each column of your 3D array, you want the max and mean  (nothing to do with any "matrix") and the output should be two 2D arrays, one for max and one for mean..

 

Here's a one-loop solution.

 

altenbach_0-1751648704291.png

 

 

EDIT: look here for an even simpler solution:

0 Kudos
Message 5 of 8
(199 Views)

@Yamaeda wrote:

Since you want to extract all pages and take the average of that, i go through all matrix positions and extract the "page column".


They attached in LabVIEW 2018 and thus might not be able to open your 2024 attachment (I cannot on my current computer)

0 Kudos
Message 6 of 8
(196 Views)
Solution
Accepted by topic author ma.arai

@altenbach wrote:
Here's a one-loop solution.

Even simpler:

 

altenbach_0-1751649549907.png

 

In a nutshell:

 

Autoindexing on a 3D array will give you one plane at each iteration in order. The loop will stop once all planes are processed.

 

We initialize two shift registers with the first plane, then iterate over the remaining planes either adding them up or keeping the largest of each 2D position. At the end, we divide the sum by the number of planes. No need for "index array" or complicated herding of cats handling of indices. 😄

 

This is relatively efficient, because planes are adjacent in memory. Column elements are not adjacent in memory and repeatedly indexing out columns in an innermost loop requires much more effort behind the scenes (i.e. getting all the widely scattered elements and assembling them into a 1D array).

 

Message 7 of 8
(189 Views)

みなさま ありがとうございます。

実際の業務に使いました。

期待値通りに動きました。

私には思い付かなかったです。

勉強になりました。

 ---------

Thank you all.

Especially Mr. altenbach.

 

I used it for actual work.

It worked as expected.

I would not have thought of it.
I learned a lot.

0 Kudos
Message 8 of 8
(134 Views)