LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiply 3D array elements by constant

I consider myself a beginner at LabVIEW.  With that said, I have a 3D array (x,y,z) where x and y both range from 0-400 and z ranges from 0-13.  I want to multiply all of the x's and y's under each z, by a different constant.  For example, x=0-400, y=0-400 and z=0, I want to multiply both x and y by 0.4.  Then for x=0-400, y=0-400 and z=1 I want to multiply x and y by 0.43 (random cosntant), and so on.

 

How can I do this?

 

Thanks in advance!

0 Kudos
Message 1 of 10
(3,805 Views)

Hi Kelly,

 

considering "z" being the 3rd index of a 3D array that would be the most straight-forward way:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,791 Views)

Can you attach a simple VI containing your 3D array as a diagram constant?

0 Kudos
Message 3 of 10
(3,789 Views)

I actually asked the wrong question.  If this thread needs to be deleted and I need to start another one, just let me know.

 

This is what I'm trying to do.  I have a 3D array (x,y,z) where x and y are pixel locations of an image (rows and columns ranging from 0-400) and z is wavelength (ranging from 0-13).  For each combination of x,y and z there is a value.  I want to hold z constant at 0 (z=0) and multiply every value at every pixel location by a constant.

 

For example x=0-400, y=0-400 and z=0.  I want to multiply the value at every combination of x and y by a constant while holding z at 0. Then move onto z=1 and multiply every combination of x and y by a different constant.

 

I attached an image of an indicator from the 3D array below.  The three white boxes are the x y and z and the fourth grey box is the value I want to change for each combination of x and y for z=0-13.

 

0 Kudos
Message 4 of 10
(3,780 Views)

X, y and z shouldn't be multiplied by the constant, only the value at the location of x, y and z.

0 Kudos
Message 5 of 10
(3,773 Views)

Hi Kelly,

 

did you notice message #2? It does exactly what you're asking for. Just replace the "random" function by your own factors...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,732 Views)

@GerdW wrote:

 It does exactly what you're asking for.


Are you sure? I don't think it reassembles the output array in the same order as the input array

0 Kudos
Message 7 of 10
(3,718 Views)

Hi Christian,

 

damn, that bl**dy autoindexing!

Ok, let's use the good old shift register with ReplaceArraySubset then...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(3,713 Views)

HI Kelly,

 

see the attachement hope that helps.

---------------- Be Good. Do Good. ---------------------
0 Kudos
Message 9 of 10
(3,710 Views)

See the attached image. This will first take a slice of 3D array, which is 2D array at specified z, then multiplies the entire data set by 10, the replace the existing data set by the new data set.

 

If you want to repeat this step on every z, you can use a For loop and a shift register to do it.

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 10 of 10
(3,692 Views)