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
///
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
new_wave[1,] += new_wave[p-1]
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 27, 2015 at 02:43 pm - Permalink
Integrate/meth=0 newWave
Display newWave
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