Forums

help needed , plotting a signal

Started by chriskatsis July 14, 2005
Hi everyone,

Just one little question.
I want to plot a signal y (where y is a column of a matrix). The
sampling rate was 500Hz
Is there a way when using the plot command (i.e. plot(y) ) to view
the time (x ax) in seconds and not in sampling points?
Thank you in advance
Christos Katsis


El 14/07/2005, a las 16:46, chriskatsis escribi

> Just one little question.
> I want to plot a signal y (where y is a column of a matrix). The
> sampling rate was 500Hz
> Is there a way when using the plot command (i.e. plot(y) ) to view
> the time (x ax) in seconds and not in sampling points?

If y is a vector, you can do this:

sf = 500;
t = (1:numel(y))/fs;
plot(t,y);

--
Juan de Dios Santander Vela
Diplomado en CC. Ficas, Ingeniero en Electrica
Doctorando en Tecnologs Multimedia
Becario Predoctoral del Instituto de Astrofica de Andaluc

Katharine Hepburn: A veces me pregunto si los hombres y mujeres se
complementan. Quizdebern vivir puerta con puerta, y hacerse
visitas de vez en cuando.



hi.... all u need to do is find the duration of signal y actually lemme
give u an example

y = sin(2*pi*f*t) where y is a sine wave of duration 5 seconds

taking the sampling rate as 500 hz make a time axis ... since sampling
rate means that u get 1 sample every 1/500 of a sec so ur signal has a
value at 0 sec 1/500 sec 2/500 sec ... just make t = 0:1/500:5 (5 is
duration of signal) and then use
plot(t,y) .. if it gives u an error saying different dimension of data
using plot or something similar .. either change t to t=1/500:1/500:5 or
t=0:1/500:5-1/500
hope this helps

--- chriskatsis <me00526@me00...> wrote:

> Hi everyone,
>
> Just one little question.
> I want to plot a signal y (where y is a column of a matrix). The
> sampling rate was 500Hz
> Is there a way when using the plot command (i.e. plot(y) ) to view
> the time (x ax) in seconds and not in sampling points? >
> Thank you in advance >
> Christos Katsis >



fs = 500;
t = 1/fs : 1/fs : (length(y)/fs);
plot(t,y); > Hi everyone,
>
> Just one little question.
> I want to plot a signal y (where y is a column of a matrix). The
> sampling rate was 500Hz
> Is there a way when using the plot command (i.e. plot(y) ) to view
> the time (x ax) in seconds and not in sampling points? >
> Thank you in advance >
> Christos Katsis


--
V Ravi Chander,
Emerging Technologies and Services Group,
Reliance Infocomm Ltd.


Hi Christos,

Simply use:

plot(1:length(y)/Fs,y)

where Fs is your sample frequency.

Jeff

-----Original Message-----
From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
chriskatsis
Sent: 14 July 2005 15:47
To: matlab@matl...
Subject: [matlab] help needed , plotting a signal Hi everyone,

Just one little question.
I want to plot a signal y (where y is a column of a matrix). The
sampling rate was 500Hz
Is there a way when using the plot command (i.e. plot(y) ) to view
the time (x ax) in seconds and not in sampling points?
Thank you in advance
Christos Katsis


hi .. i dont think jeff's solution wud work .. incase the length of y is
500 ie equal to Fs the plot function wud give an error "vector length
mismatch or something" ...

--- Jeff Winter <jeff.winter@jeff...> wrote:

> Hi Christos,
>
> Simply use:
>
> plot(1:length(y)/Fs,y)
>
> where Fs is your sample frequency.
>
> Jeff
>
> -----Original Message-----
> From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
> chriskatsis
> Sent: 14 July 2005 15:47
> To: matlab@matl...
> Subject: [matlab] help needed , plotting a signal > Hi everyone,
>
> Just one little question.
> I want to plot a signal y (where y is a column of a matrix). The
> sampling rate was 500Hz
> Is there a way when using the plot command (i.e. plot(y) ) to view
> the time (x ax) in seconds and not in sampling points? >
> Thank you in advance >
> Christos Katsis >


Hi,

Sorry missed some brackets, should be:

plot((1:length(y))/Fs,y)

Jeff

-----Original Message-----
From: Amit Pathania [mailto:amit_pathania30@amit...]
Sent: 15 July 2005 11:21
To: jeff.winter@jeff...; chriskatsis; matlab@matl...
Subject: RE: [matlab] help needed , plotting a signal hi .. i dont think jeff's solution wud work .. incase the length of y is
500 ie equal to Fs the plot function wud give an error "vector length
mismatch or something" ...

--- Jeff Winter <jeff.winter@jeff...> wrote:

> Hi Christos,
>
> Simply use:
>
> plot(1:length(y)/Fs,y)
>
> where Fs is your sample frequency.
>
> Jeff
>
> -----Original Message-----
> From: matlab@matl... [mailto:matlab@matl...]On Behalf Of
> chriskatsis
> Sent: 14 July 2005 15:47
> To: matlab@matl...
> Subject: [matlab] help needed , plotting a signal > Hi everyone,
>
> Just one little question.
> I want to plot a signal y (where y is a column of a matrix). The
> sampling rate was 500Hz
> Is there a way when using the plot command (i.e. plot(y) ) to view
> the time (x ax) in seconds and not in sampling points? >
> Thank you in advance >
> Christos Katsis


__________________________________________________





[y,fs]=wavread('sound');

L=length(y);

%plot frame in time domain
t=[0:1/fs:(511)/fs]
figure(1);
plot(t,vc),axis tight,xlabel('Time (s)'),grid on;
--- V Ravi Chander <ravichander_vipperla@ravi...>
wrote:

> fs = 500;
> t = 1/fs : 1/fs : (length(y)/fs);
> plot(t,y); > > Hi everyone,
> >
> > Just one little question.
> > I want to plot a signal y (where y is a column of
> a matrix). The
> > sampling rate was 500Hz
> > Is there a way when using the plot command (i.e.
> plot(y) ) to view
> > the time (x ax) in seconds and not in sampling
> points?
> >
> >
> >
> > Thank you in advance
> >
> >
> >
> > Christos Katsis
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> V Ravi Chander,
> Emerging Technologies and Services Group,
> Reliance Infocomm Ltd.


__________________________________________________