![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
running sum code
epiphenom
ex. if points in old wave are 1,1,2,3 ----------- new wave would be 1,2,4,7
This is the code that I need help with:
#pragma rtGlobals=3 // Use modern global access method and strict wave access. /// Function go() Wave new Wave old_wave Make /O new Variable run_sum = 0 Variable curr_val Variable p=0 curr_val = old_wave[p] do new[p] = run_sum + old_wave[p] p+=1 run_sum += curr_val while (p <= numpnts(old_wave)) return curr_val display new end
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 27, 2015 at 02:43 pm - Permalink
If you insist on writing an explicit loop you may want to stay away from using 'p' as an index as it has other uses.
A.G.
WaveMetrics, Inc.
January 27, 2015 at 02:46 pm - Permalink
January 27, 2015 at 10:13 pm - Permalink