LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to calculate the mean of a section of an array?

Here is the another method.

Find the attachement.

 

-Kumar.

0 Kudos
Message 11 of 19
(1,301 Views)
thank you kumar
0 Kudos
Message 12 of 19
(1,280 Views)
I'm not near an LV PC to test this, but wouldn't there be some possible issues about the implied floating-point equality going on in altenbach's "Search 1D Array" approach?  Doesn't it depend on where the 0 values came from and whether they are, in fact, true 0?
 
When I've wanted to check for "proximity to 0" with processed data, I've used the "In Range and Coerce" primitive with very small bounds like +/- 1.0e-6.   You could then search the Boolean 'In Range?' array output for "True" instead of searching the original floating point array for 0.
 
-Kevin P.
 
EDIT: typo correction

Message Edited by Kevin Price on 02-15-2007 02:00 PM

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 13 of 19
(1,274 Views)

Kumar,

Be aware that all these constant array resizings are very expensive because the cause constant memory reallocations. You method is not recommended for larger aray inputs.

For example with an input array of 100000 points with section of random lenght of 1..10 elements, your solution takes almost 3 seconds, while my version does it all in 70milliseconds. A 50x speed penalty! 100000 points is not that much, but 3 seconds is a very long time!

Even my code is not fully optimized. For example skipping the initialize array and do the replacement "in place" (See image) using an inner loop and another shift register drops the time down to 45ms because we don't need to allocate the averaged subarrays.

I am sure many other improvements are possible. This was just a quick "back of the envelope" draft. 🙂

 

Message Edited by altenbach on 02-15-2007 11:19 AM

0 Kudos
Message 14 of 19
(1,270 Views)


@Kevin Price wrote:
I'm not near an LV PC to test this, but wouldn't there be some possible issues about the implied floating-point equality going on in altenbach's "Search 1D Array" approach?  Doesn't it depend on where the 0 values came from and whether they are, in fact, true 0?
 
When I've wanted to check for "proximity to 0" with processed data, I've used the "In Range and Coerce" primitive with very small bounds like +/- 1.0e-6.   You could then search the Boolean 'In Range?' array output for "True" instead of searching the original floating point array for 0.
 
-Kevin P.

Kevin

In the real world, this is certainly a concern but the posted data contained only "true zeroes" so that's what I assumed. Maybe they come from an output tunnel set to use default if unwired? Maybe he start out with an all zero array and replaces acquired data subsections at random locations?

The bounds of course need to be adjusted according to the data, for example if the data is in nanovolts bounds of 1e-6 are huge. 🙂

Thanks for pointing out this potential issue.

0 Kudos
Message 15 of 19
(1,264 Views)
Guys hello
 
first of all i want to thank evry single one for his time and effort to help me in my problem.i have read all your posts and i see where and at what point each one of you is concerned. the array i put here was the output array from a bigger vi i have built.
 
basically what i am doing is loading a wave file into labview and trying to time and pitch scale it using the Cepstrum algorithm for pitch period estimation and using the TD-PSOLA technique.at this point i have estimated the pitch periods in the signal and trying to segment the signal according to those periods. the array i have posted here is the resulting array of these pitch periods. 0 (zero) represents unvoiced segments and numbered elements represent the pitch period present in a segment.
i have posted the rest of my program with a sample wave file if someone wants to give it a look and tell me what they think. any pointers would be much appreciated again.
 
kind regards
madgreek
 
 
Download All
0 Kudos
Message 16 of 19
(1,260 Views)
I'll have to look at this tonight or over the weekend, but here are a few simple things I noticed.
  • The "reshape array" does notthing useful, you might as well leave it out.
  • That "polling loop" in the upper right corner needs a wait statement, else it will consume all CPU, starving everything else (check with task manager). You could use an event structure for example.
  • Why do you even need to pause after each iteration, the only input is the window type which will only apply to the next, not the current segment. Changing the window during run seems dangerous, because there will be no record in the output data on what window was used where. It might be safer to pull the window control out of the loop so it is consistent across e run.
  • Make that diagram constat going to the search node DBL (right-click...representation). RIght now your I32 "zero" gets converted to DBL at each iteration. (look out for coercion dots!)

Instead of having linear code, it might be more useful to make an ineractive state machine where you can go back and forth through the sound segments at will and adjust the parameters dynamically until everything looks right.

Message Edited by altenbach on 02-15-2007 03:09 PM

0 Kudos
Message 17 of 19
(1,246 Views)
Altenbach
 
i went through almost all your suggestions. i used the reshape array to reshape the last segment of the sound file so as to be the same size as the previous ones.i thought it would be best to do so.the while loop at the upper right corner is a left over from my simulations up to now where i had to go through all the segments "manually" and compare my results from cepstrum to that of ACF (autocorrelation) so as to make sure everything was working right. as far as the window control, i just wanted to be able to run my vi with different windows and see any changes. i did all these things you suggested.
no matter what though, thank you for all your help and time devoted.
 
kind regards
madgreek
 
0 Kudos
Message 18 of 19
(1,242 Views)

Altenbach

did you have a chance to go through my vi?if you did, i am really eager to find out what you think about it and if you have any tips for me

kind regards

madgreek

0 Kudos
Message 19 of 19
(1,208 Views)