# matlab changing time scale on a waveform

• Jul 26th 2009, 04:12 PM
edm
matlab changing time scale on a waveform
hi,

i have a waveform which i have read in using matlab.

fs = 200, waveform length = 20s.

if i read in waveform and plot() it, without setting 't', matlab will auto generate a scale from 0 to 4000

using plot(waveform(1800:2200)) will show me 2 cycles.

and i can plot the full waveform with correct time scale by t=(0:length(ecgclean)-1)/fs;

but how can plot waveform only over 2 cycles using the correct time scale?

arghh, i know it will be trival but i just cant get it work!

thanks for any help
• Jul 26th 2009, 08:04 PM
CaptainBlack
Quote:

Originally Posted by edm
hi,

i have a waveform which i have read in using matlab.

fs = 200, waveform length = 20s.

if i read in waveform and plot() it, without setting 't', matlab will auto generate a scale from 0 to 4000

No it won't look more closely the scale runs from 1 to the number of sample points.

CB
• Jul 26th 2009, 08:07 PM
CaptainBlack
Quote:

Originally Posted by edm
hi,

i have a waveform which i have read in using matlab.

fs = 200, waveform length = 20s.

if i read in waveform and plot() it, without setting 't', matlab will auto generate a scale from 0 to 4000

using plot(waveform(1800:2200)) will show me 2 cycles.

and i can plot the full waveform with correct time scale by t=(0:length(ecgclean)-1)/fs;

but how can plot waveform only over 2 cycles using the correct time scale?

arghh, i know it will be trival but i just cant get it work!

thanks for any help

Code:

```ddata=ecgclean(1800:2200); plot([0:length(ddata)-1]/fs,ddata);```
CB
• Jul 27th 2009, 09:06 AM
edm
great, thanks for you help CB!