LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimate an array to a fixed length

Solved!
Go to solution

Hello

 

I am plotting some data in 3D and is rather slow... so I am trying to decimate an array to a fixed length (I know the decimate function, it's not that simple) :

If I have an array of length N and want to decimate to an array of length M (both N and M are decided at runtime). I made something like this, I am wondering if you have a better way.

It's not that important, this thing works for me, but just wondering if there is a better way.

Thanks

 

nitad54449_0-1692783176736.png

 

0 Kudos
Message 1 of 11
(1,285 Views)

Hi nitad,

 


@nitad54449 wrote:

I made something like this, I am wondering if you have a better way.


  • You only need to divide once before the loop.
  • You can index the array elements inside your own loop so you don't need that additional green function with its own loop inside…
Best regards,
GerdW


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

Hi

The divide in the loop is a rookie mistake,... but I don't get your second comment. I want to delete those indexes (or should I do it the other way around ? I mean I could use a conditional indexer, I was thinking this is slow). 

(well, slow, is maybe not that important but the "array in" has typically 2k to 10k length, each element is a cluster with 5 to 10 arrays of 100 to 500 doubles...)

thanks

0 Kudos
Message 3 of 11
(1,271 Views)

Hi nitad,

 


@nitad54449 wrote:

I want to delete those indexes (or should I do it the other way around ? I mean I could use a conditional indexer, I was thinking this is slow). 

I don't use those green functions (OpenG? GPower?) so I cannot comment in their purpose just from looking at the image.

When I "decimate" an array I typically pick the elements that should remain instead of deleting all other elements - should be more performant when the decimation factor is >>1…

 


@nitad54449 wrote:

the "array in" has typically 2k to 10k length, each element is a cluster with 5 to 10 arrays of 100 to 500 doubles...)


Your "array in" is a 1D array of I32 values according to the image!? No clusters, no DBLs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(1,255 Views)

Hi

I put a simplified version, here is a real life vi

it takes 27 msec on my computer (the green stuff is openG)

0 Kudos
Message 5 of 11
(1,244 Views)

Hi nitad,

 

mind to share the VI downconverted to LV2019?

Best regards,
GerdW


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

Hi

Here it is in 2019

A simpler version without OpenG (11 msec now), Vi attached.

nitad54449_0-1692794175051.png

 

 

Message 7 of 11
(1,232 Views)

"Delete from array" should never be inside a tight loop! I'll have a look.

Message 8 of 11
(1,218 Views)
Solution
Accepted by topic author nitad54449

Hi nitad,

 

so you want to pick 200 elements out of ~3700 elements, so the solution is to delete ~3500 elements from the array?

 

I repeat: I would just pick the elements I need:

You may use a different rounding (or no rounding at all as ToI32 will also round)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(1,214 Views)

Hi

Nice, this Ramp stuff..

Now is in the msec range !

 

Thanks

0 Kudos
Message 10 of 11
(1,205 Views)