LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (11/3/2009) - Decimate 1D Array

A fairly useful function for today "Decimate 1D Array".  Once I got used to this function, I found myself adapting my code to take advantage of it.  The function is like a dealer for arrays (back from Vegas, sorry), and you resize it to select the number of "hands".  (If you are one of those deal-from-the-bottom-of-deck types, you could reverse the array first).  Part of the getting used to this function phase was realizing that it will only return arrays with the same size, if the array is one element short, all arrays drop the last element.  Sometimes I wish that were a selectable behavior, but I am used to it now.

 

I probably use this most often to squeeze my complex data into the curve fitting VIs.  I interleave the real and imaginary components, pass the 1D array, and then decimate to retrieve the components.  No need to keep track or calculate the number of points.

 

Decimate1DArray.png 

 

VIOTD groundrules here

Message 1 of 9
(4,578 Views)

Darin.K wrote:

I probably use this most often to squeeze my complex data into the curve fitting VIs.  I interleave the real and imaginary components, pass the 1D array, and then decimate to retrieve the components.  No need to keep track or calculate the number of points.


You probably got this from one of my old VIs. 😉

 

While it is explicit and easy to read, you could also get the same effect by typecasting the CDB array to a DBL array and later typecast it back to a CDB. It should give the same result, but might be a bit more efficient because the layout in memory remains the same. I have not benchmarked it.

Message 2 of 9
(4,559 Views)

Here's what I meant (Hey, I made a snippet!!!) 🙂

 

 

Message Edited by altenbach on 11-03-2009 08:00 AM
Message 3 of 9
(4,549 Views)

I'll guess from the joy of snippet creation and the fact that your controls are displayed as icons means you've recently upgraded.  Smiley Wink

 

I would like to pin the blame on you, but the original code and its inefficiencies were my own creation.  That is moot now, typecasting wins hands down and will be pilfered repeatedly in the future.

0 Kudos
Message 4 of 9
(4,508 Views)

Darin.K wrote:

I would like to pin the blame on you, but the original code and its inefficiencies were my own creation. 


I don't doubt it. Great minds think alike .... 🙂

 

(What I had in the back of my mind is for example the old XuFit stuff from 2005.)

0 Kudos
Message 5 of 9
(4,484 Views)

Darin.K wrote:

I'll guess from the joy of snippet creation and the fact that your controls are displayed as icons means you've recently upgraded.  Smiley Wink


Interesting observation. All I did was drag your snipped (with the plain terminals!) to the diagram of a blank VI and the terminals turned into icons. I guess snippets will adapt to the preferences setting. I never noticed that and I don't really like it! For example it will overlap the terminals connected to the upper "decimate" outputs. Not pretty!

 

To be honest, I usually don't bother to change most of the defaults and usually only change the terminal style when the diagram space gets crowded. 😉 (Still, I wish there was an option to select a bunch of terminals and change the icon style of the entire group...)

 

Yes, we are on SSP and I am typically an early adopter. I took the plunge and do virtually all development in LV2009 these days. No major issues so far. 🙂

0 Kudos
Message 6 of 9
(4,433 Views)

Those icons took up the space of your average for loop.  Smiley Very Happy

 

With 3+ versions of LV on 3 machines, I still haven't changed that preference on all (most) of them.  It is funny how many little things the snippets do to code.  Overall, though, I am still a huge fan. 

0 Kudos
Message 7 of 9
(4,423 Views)

altenbach wrote:

 

(Still, I wish there was an option to select a bunch of terminals and change the icon style of the entire group...)

 


See this VI I made.  It uses LV scripting.  (File is in LV 8.6, but it also works in LV2009)

 

1.  Run this VI.

2.  Have the block diagram you want to fix active.

3.  Click the button on this VI.  It changes all terminals to the small style.

Message 8 of 9
(4,416 Views)
Decimate works well feeding a lot of data into a graph. The graph doesn't need to update as often and it improves the performance of the application.
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 9 of 9
(4,393 Views)