Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
query about function output

Subject: query about function output

From: Dhanashree

Date: 24 Dec, 2013 06:58:05

Message: 1 of 5

y=abs(x_fft(1:M/2,:));
imagesc(t,f,dB(y))

imagesc gives me the spectrogram.that is i have used that function to plot the spectrogram.y is giving the magnitude of the fft calculated.In the above function what does dB(y) do? when i use only y i get complete ble coloured spectrogram.plz help.

Subject: query about function output

From: Loren Shure

Date: 24 Dec, 2013 15:21:25

Message: 2 of 5

"Dhanashree " <dhanurane17@gmail.com> wrote in message
news:l9bb9t$kbi$1@newscl01ah.mathworks.com...
> y=abs(x_fft(1:M/2,:));
> imagesc(t,f,dB(y))
>
> imagesc gives me the spectrogram.that is i have used that function to plot
> the spectrogram.y is giving the magnitude of the fft calculated.In the
> above function what does dB(y) do? when i use only y i get complete ble
> coloured spectrogram.plz help.
>

dB is either a function that you have or a variable you haven't shown us
yet. It looks like it's meant to be a decibel calculation, but without the
code, hard to say...



--
--Loren

http://blogs.mathworks.com/loren

Subject: query about function output

From: Dhanashree

Date: 25 Dec, 2013 16:07:05

Message: 3 of 5

"Loren Shure" wrote in message <l9c8pl$sqb$1@newscl01ah.mathworks.com>...
> "Dhanashree " <dhanurane17@gmail.com> wrote in message
> news:l9bb9t$kbi$1@newscl01ah.mathworks.com...
> > y=abs(x_fft(1:M/2,:));
> > imagesc(t,f,dB(y))
> >
> > imagesc gives me the spectrogram.that is i have used that function to plot
> > the spectrogram.y is giving the magnitude of the fft calculated.In the
> > above function what does dB(y) do? when i use only y i get complete ble
> > coloured spectrogram.plz help.
> >
>
> dB is either a function that you have or a variable you haven't shown us
> yet. It looks like it's meant to be a decibel calculation, but without the
> code, hard to say...
>
>
>
> --
> --Loren
>
> http://blogs.mathworks.com/loren
ok.....i am giving you the whole program i have.It is basically program to plot spectrogram.plz explain it to me.

M=256;
B=floor(N/M);
x_mat=reshape(x(1:M*B),[M B]);
hamming(M);
win_mat=repmat(hamming(M),[1 B]);
x_fft=(x_mat.*win_mat);
y=abs(x_fft(1:M/2,:));
t=(1:B)*(M/fs);
f=((0:M-1)/(M-1)*(fs/2));
f;
%bark=frq2bark(f);
%bark=13.*atan(0.00076*f)+3.5.*atan((f/7500)^2);
figure(2);
imagesc(t,f,dB(y));
colormap(jet);
colorbar;
set(gca,'ydir','normal');
xlabel('Time(sec)');
ylabel('Frequency(Hz)');
title('Spectrogram');

Subject: query about function output

From: Loren Shure

Date: 26 Dec, 2013 12:22:59

Message: 4 of 5


"Dhanashree " <dhanurane17@gmail.com> wrote in message
news:l9evr9$sbm$1@newscl01ah.mathworks.com...
> "Loren Shure" wrote in message <l9c8pl$sqb$1@newscl01ah.mathworks.com>...
>> "Dhanashree " <dhanurane17@gmail.com> wrote in message
>> news:l9bb9t$kbi$1@newscl01ah.mathworks.com...

>> dB is either a function that you have or a variable you haven't shown us
>> yet. It looks like it's meant to be a decibel calculation, but without
>> the code, hard to say...
>>
>>
>>
>> --
>> --Loren
>>
>> http://blogs.mathworks.com/loren
> ok.....i am giving you the whole program i have.It is basically program to
> plot spectrogram.plz explain it to me.
>
> M=256;
> B=floor(N/M);
> x_mat=reshape(x(1:M*B),[M B]);
> hamming(M);
> win_mat=repmat(hamming(M),[1 B]);
> x_fft=(x_mat.*win_mat);
> y=abs(x_fft(1:M/2,:));
> t=(1:B)*(M/fs);
> f=((0:M-1)/(M-1)*(fs/2));
> f;
> %bark=frq2bark(f);
> %bark=13.*atan(0.00076*f)+3.5.*atan((f/7500)^2);
> figure(2);
> imagesc(t,f,dB(y));
> colormap(jet);
> colorbar;
> set(gca,'ydir','normal');
> xlabel('Time(sec)');
> ylabel('Frequency(Hz)');
> title('Spectrogram');

As stated earlier and with this code, it looks like dB must be a function.
In MATLAB, try

which dB

to see if there's such a file on your matlabpath. Then you can either get
help for it or edit it to see what it does.

--Loren

http://blogs.mathworks.com/loren

Subject: query about function output

From: Nasser M. Abbasi

Date: 26 Dec, 2013 12:45:35

Message: 5 of 5

On 12/26/2013 6:22 AM, Loren Shure wrote:

> As stated earlier and with this code, it looks like dB must be a function.
> In MATLAB, try
>
> which dB
>
> to see if there's such a file on your matlabpath. Then you can either get
> help for it or edit it to see what it does.
>
> --Loren
>
> http://blogs.mathworks.com/loren
>

dB is a matlab function. In signal processing toolbox

EDU>> help db
  db Convert to decibels.
     db(X) converts the elements of X to decibel units
     across a 1 Ohm load. The elements of X are assumed
     to represent voltage measurements.

EDU>> which db
C:\Program Files (x86)\MATLAB\R2013a Student\toolbox\signal\signal\db.m

http://www.mathworks.com/help/signal/ref/db.html
"Convert energy or power measurements to decibels"

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us