Index out of range

Hello,

I'm trying to do the following:

make/n=7000 baseline
make/n=9000 perturbation
make/n=9000 final

and I want to set final=perturbation+baseline such that the last 2000 points of final are the last 2000 points of perturbation. Can you please help me with the indexing?

Thanks so much,

Nicole

Thanks. But here is my actual code:

make/o/N=70000 sos_ramp_wave=1
make/o/N=333 sos_ramp_wave_on
make/o/N=333 sos_ramp_wave_off

sos_ramp_wave[0,332]= sos_ramp_wave_on
sos_ramp_wave[333, 69999]= sos_ramp_wave_off

I get an error that "sos_ramp_wave_off index out of range". And what the code does is it adds sos_ramp_wave_on to the beginning of sos_ramp_wave, but then takes the last value of sos_ramp_wave_off and repeats it 333 times at the end of sos_ramp_wave.
ndanos wrote:
sos_ramp_wave[333, 69999]= sos_ramp_wave_off


I'm curious what you expect to happen, since sos_ramp_wave_off has only 333 points in it, but you are trying to fill 70000-333 69667 points.
If you want the next 333 points to be filled from sos_ramp_wave_off, you could do this:
 sos_ramp_wave[333,665] = sos_ramp_wave_off[p-333]
The range is 333 to 665 because the range indexing uses inclusive end points.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Sorry, John,

There was a typo in my code. The correct code that I'm actually using is:

sos_ramp_wave[0,332]= sos_ramp_wave_on
sos_ramp_wave[69666, 69999]= sos_ramp_wave_off// tried with [p-333]

And I still get the index out of bounds error.

Even if I had the index wrong, why is only the last value of sos_ramp_wave_off being copied in sos_ramp_wave? And why does it work for sos_ramp_wave_on without the extra reference?


Thanks in advance.

 

Hi,

This should work:

make/o/N=70000 sos_ramp_wave=1
make/o/N=333 sos_ramp_wave_on
make/o/N=333 sos_ramp_wave_off

sos_ramp_wave[0,332]= sos_ramp_wave_on
sos_ramp_wave[<strong>69667</strong>, 69999]= sos_ramp_wave_off[<strong>p - 69667</strong>]
Note that igor implicitly 'loops' the right hand side of a wave assignment through the left hand side point range.

 

Thank you so much- that does work!

I still don't quite understand the indexing on the right handside, and why it should be different for the on vs off wave.
As you have figured out, a wave assignment is simply a loop, and the p function on the right-hand side just sequentially takes on the point numbers seen on the left-hand side of that loop. So in

sos_ramp_wave[69667, 69999]= sos_ramp_wave_off[p - 69667]

p runs from 69667 to 69999. But the row numbers in sos_ramp_wave_off are in the range [0,332], so you have to subtract 69667 to get row numbers appropriate to sos_ramp_wave_off.

Please read more than you ever wanted to know about this:
DisplayHelpTopic "Waveform Arithmetic and Assignment"

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com