
Index out of range

ndanos
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
Remember that Igor indices are zero-based. Count starting at zero!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
November 3, 2015 at 05:16 pm - Permalink
Andy
November 3, 2015 at 06:42 pm - Permalink
Or, if you prefer, we have 1010 fingers.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
November 4, 2015 at 09:24 am - Permalink
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.
November 5, 2015 at 09:27 am - Permalink
I feel inadequate with only 110 fingers :)
steve
November 5, 2015 at 07:34 am - Permalink
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
November 5, 2015 at 10:09 am - Permalink
Oops. And I'm supposed to be the professional!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
November 5, 2015 at 10:10 am - Permalink
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.
November 5, 2015 at 11:15 am - Permalink
Hi,
This should work:
November 5, 2015 at 01:02 pm - Permalink
I still don't quite understand the indexing on the right handside, and why it should be different for the on vs off wave.
November 5, 2015 at 01:43 pm - Permalink
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
November 6, 2015 at 05:10 pm - Permalink