electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

spectrum analysis code in MaTLaB(urgently required)


Goto page 1, 2  Next
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> spectrum analysis code in MaTLaB(urgently required)
Author Message
munaim



Joined: 13 Apr 2007
Posts: 37


Post27 Apr 2007 20:29   

spectral analysis matlab


i m new in matlab so i want code of spectrum analysis in MATALB
i need it urgently
Back to top
mondunno



Joined: 11 Jan 2007
Posts: 138
Helped: 11


Post27 Apr 2007 20:30   

matlab spectrum analyzer


use freqz, whatz exactly u need? hope freqz command is enough
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post27 Apr 2007 20:34   

matlab spectrum analysis


i have been given project of spectrum analysis but i m new in matlab.....
n i want that code which is not 4 any specific 4m any frez it will b generalized one .......
i will b very thankful 2 u !!!
Back to top
Google
AdSense
Google Adsense




Post27 Apr 2007 20:34   

Ads




Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post28 Apr 2007 1:25   

spectrum analyzer matlab


At the matlab command prompt type

"help pwelch"

and go from there.


Dave
Back to top
artsil23



Joined: 08 Sep 2006
Posts: 315
Helped: 179


Post28 Apr 2007 4:30   

matlab spectral analysis


principal program:

%
% The spectrum of a process x is estimated using Welch's method
% of averaging modified periodograms.
%
% x : input sequence
% L : section length
% over: amount of overlap, where 0<over<1,
% win : The window type
% 1 = Rectangular
% 2 = Hamming
% 3 = Hanning
% 4 = Bartlett
% 5 = Blackman
%
% Welch's estimate of the power spectrum is returned in Px
% using a linear scale.
%
% see also BART, MPER, PER, and SPER
%


if (nargin <= 3) win=1; end;
if (nargin <= 2) over=0; end;
if (nargin == 1) L=length(x); end
if (over >= 1) | (over < 0)
error('Overlap is invalid'), end
n1 = 1;
n2 = L;
n0 = (1-over)*L;
nsect=1+floor((length(x)-L)/(n0));
Px=0;
for i=1:nsect
Px = Px + mper(x,win,n1,n2)/nsect;
n1 = n1 + n0;
n2 = n2 + n0;
end;

auxiliar function:

function Px = mper(x,win,n1,n2)
%MPER Spectrum estimation using the modified periodogram.
%----
%USAGE Px = mper(x,win,n1,n2)
%
% The spectrum of a process x is estimated using the modified
% periodogrm.
%
% x : input sequence
% n1 : starting index, x(n1)
% n2 : ending index, x(n2)
% win : The window type
% 1 = Rectangular
% 2 = Hamming
% 3 = Hanning
% 4 = Bartlett
% 5 = Blackman
%
% If n1 and n2 are not specified the periodogram of the entire
% sequence is computed.
%
% The modified periodogram is returned in Px using a linear scale.
%
% see also BART, PER, SPER, and WELCH
%


x = x(Smile;
if nargin == 2
n1 = 1; n2 = length(x); end;
N = n2 - n1 +1;
w = ones(N,1);
if (win == 2) w = hamming(N);
elseif (win == 3) w = hanning(N);
elseif (win == 4) w = bartlett(N);
elseif (win == 5) w = blackman(N);
end;
U = norm(w)^2/N;
xw = x(n1:n2).*w;
Px = abs(fft(xw,1024)).^2/(N*U);
Px(1)=Px(2);
end;
Back to top
sinak



Joined: 26 Feb 2006
Posts: 13


Post28 Apr 2007 14:51   

matlab pwelch


you look at this link.

http://www.istanbul.edu.tr/eng/ee/courses/matlab/MATLAB%20Tutorials%20for%20Undergraduate%20Courses.htm
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post29 Apr 2007 18:36   

pwelch matlab


thxxxx 4 the code but i dun want any code of welch n........???simply i wannit to learn how to make spectum analysis through matlab.and how dats works.....i will b very thankful 2 u !!!
Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post29 Apr 2007 21:00   

power spectrum matlab code


pwelch is the matlab command to use. If you read the documentation for pwelch, you will learn how to do spectrum analysis in matlab. You can thank me later.


Dave
Back to top
rajsrikanth



Joined: 19 Apr 2006
Posts: 132
Helped: 8
Location: Hyderabad


Post30 Apr 2007 4:41   

amplitude spectrum matlab


try this coding for finding spectral analysis


x=x/(power(10,-8.5));
[Pxx,W] = pwelchcustom(x,200,90,64,10000);
Pxx2 = 10 * log10(abs(Pxx));
figure(10),plot(w,Pxx2),
title('power spectrum of chirp data'),
xlabel('Frequency(hz)');
ylabel('SPL (db)');
Back to top
rsrinivas



Joined: 10 Oct 2006
Posts: 419
Helped: 36
Location: bengalooru


Post30 Apr 2007 5:04   

spectrogram matlab code


spectogram or specgram command depends on ur matlab ver
Back to top
supiper



Joined: 26 Jan 2007
Posts: 241
Helped: 114
Location: TUNISIA


Post30 Apr 2007 8:17   

spectrogram matlab


For speech spectrum analysis you can download the Toolbox from this link:
http://www.edaboard.com/viewtopic.php?t=223822&highlight=speech
You can used for any signal.
You can also download other Toolbox from the Net like: WeveLab
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post30 Apr 2007 11:00   

matlab spectrogram


thank u everone !!!
but i have told that i have been given project to make spectrum analysis!!!
is it feasible to make thorugh software??
or if i have to make through with harware then how can i make it!!!
please tell me !!!
i will b very thankful to u !!!
nyvz thxxxxx alot once again 4 ur cooperation ....
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post01 May 2007 12:08   

matlab microphone


hello everybody !!
still i m in fix to do dat !!!
do u knoe any link from where i get any information regarding spectrum analysis ....is it feasible to make it through software??
Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post02 May 2007 3:30   

matlab audio spectrogram


Several posters have told you how to do it in software. It's certainly possible to do in matlab. What data are you trying to do a spectrum analysis on?

Dave
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post02 May 2007 7:17   

spectrum analysis matlab


i have tried to run that principal program by dave but it ain't working.....if u have ryt code of spectrum analysis den plzz provide me m facing problem in it!!!i juz want code in matlab dats it!!!
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post10 May 2007 21:28   

spectrum analyzer in matlab


i want code of spectrum analysis in matlab .....simply whatever u or i will speak i can see the frequency spectrum of that voices on dat .......analyser so if u will help me .......
Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post11 May 2007 0:18   

spectrum analysis in matlab


Why don't you read this first, and you'll get further

http://www.catb.org/~esr/faqs/smart-questions.html

Dave
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post11 May 2007 2:12   

spectrum analysis using matlab


Hi munaim, RFDave has made a good point: you need to ask your question more clearly. The phrase "spectrum analysis" applies to a wide variety of physics and engineering projects.

You mentioned speech. Do you want to speak into a microphone, and use MATLAB to display the audio frequency spectrum? If that's correct, do you need an ordinary frequency-amplitude graph, or do you need a spectrogram? Do you need real-time display update?

Maybe this will help you:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9603&objectType=file
Or maybe one of these:
http://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do?objectId=67&objectType=Category
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post13 May 2007 11:46   

power spectral analysis matlab


i want to display output on computer through code of matlab n 3 techniques which u have told me ......i want to use the simplest one ............
simply i write that code and having such interface that when i will speak through mic den it will show frequency spectrum of that ..........
n tells how frequency vary with voice .....
i think so now its clear ....
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post15 May 2007 11:12   

matlab code source for power spectrum


RF dave and other members of edaboard plzzzzz tell me the code n i have told the whole situation to u in previous post .......so plzzzzz tell me
i will b veryy thankful 2 u !!!
Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post17 May 2007 3:14   

matlab codes for attenuation vs frequency graph


Sorry, there isn't a simple code to do what you want to do. If I were doing this, I would do the following. I don't know how to do any of these things, but this is the approach I would take.

1-figure out how to record audio from a microphone into a matlab file. Poke around in the matlab documentation for audio input and output, I've seen some help pages on that, so I know that they exist. You'll probably have to start by recording a couple of second long audio clip.

2-Once you have the audio data, you can compute the power spectral density. pwelch would be my recommendation, but there are other possibilities for computing the power spectral density, and there are tradeoff's to be made.

3-Plot the power spectral density. THis is pretty straightforward with the plot command.

4-Once you have this working, you can iterate on your matlab until it's doing what you want.

Dave
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post17 May 2007 5:24   

spectrogram code


munaim, The first link I gave you contains a real-time audio spectrum analyzer.
Unzip the files (skip corrupt trashtruck.wav), run slm.m, talk into your microphone, and watch the animated spectrum plot.
The documentation says it requires the MATLAB Data Acquisition Toolbox.
Back to top
amihomo



Joined: 09 Jan 2007
Posts: 206
Helped: 23
Location: Tehran,Iran


Post21 May 2007 2:58   

power spectrum analysis matlab


I think the data aquisition toolbox in Matlab can help you.
Back to top
rsrinivas



Joined: 10 Oct 2006
Posts: 419
Helped: 36
Location: bengalooru


Post21 May 2007 5:23   

matlab code warped mvdr spectral estimation


amihomo wrote:
I think the data aquisition toolbox in Matlab can help you.

that's only to manage data access to matlab from external components through the pc.
Back to top
mehboob_iiui



Joined: 20 May 2006
Posts: 147
Helped: 5
Location: Rawalpindi - Pakistan


Post21 May 2007 14:02   

spectrogram command + matlab example code


function showfft(y,Fs)

L=length(y);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

% save it as showfft.m in your current directory
% I find it to be very useful in frequency analysis of signals
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post25 May 2007 10:52   

how to use dpss for spectral analysis matlab


simply sumone will speak from microphone and have a spectrum which is being provided by matlab coding dats it !!!!i want dat code siimply
Back to top
RFDave



Joined: 18 Feb 2004
Posts: 346
Helped: 45
Location: NE USA


Post25 May 2007 11:30   

spectrum analysis with matlab


What have you done with all of the suggestions that you've received? Have you tried any of them?

Dave
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post11 Jun 2007 12:34   

spectral method matlab


yeah i have tried almost all ov them , but i m not gtetting required output..... i have run almost all ov the programs but every code has a flaw....dats y matlab is not showing me any sort of output ........
Mr DAVE i want that if sum one will speak in mic then he can see the spectrum of his voice whatever he speaks.
i want code of this simply
simply matlab code n how to connect it through mic to speak ,either in normal port or some special ........
i will be very thankful 2 u !!!!
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post11 Jun 2007 14:30   

matlab read microphone


This requires the Signal Processing Toolbox.
Code:
% Audio spectrum display. To exit, close the figure.
%
Fs = 22050;                                 % sample rate, hertz
T  = 0.2;                                   % sample duration, seconds
Hs = spectrum.welch('blackman',1024,20);    % configure the transform
gca;                                        % open the figure
while get(0,'CurrentFigure')                % while figure still open
  signal = wavrecord(T*Fs,Fs);              % acquire some signal
  psd(Hs, signal,'Fs',Fs); ylim([-160 0]);  % transform and plot
  pause(0.001);                             % allow figure to update
end
Back to top
munaim



Joined: 13 Apr 2007
Posts: 37


Post11 Jun 2007 19:39   

power spectrum of a signal matlab code


Error using ==> uimenu
Invalid object handle.

Error in ==> echo47 at 9
psd(Hs, signal,'Fs',Fs); ylim([-160 0]); % transform and plot



i have run dat code in matlab but its giving me the error which i have copied in the upper lines.......
i have got the output but it changes after 3 seconds .......
i want that any user will speak thorugh mic n that voice spectrum will b shown .....
do i have to connect mic through it or wht i have to do 4 reteriving my voice spectrum ....
plzzzzzz tell me i want it urhgently coz deadline date is juzzzzzz .......
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> spectrum analysis code in MaTLaB(urgently required)
Page 1 of 2 All times are GMT + 1 Hour
Goto page 1, 2  Next
Similar topics:
help!!! precise spectrum analysis using Matlab (1)
Matlab program required for error coding URGENTLY (2)
spectrum analysis with the fft basics and Matlab 4 begineers (12)
audio spectrum - need help with the Matlab code (3)
i need MATLAB code for DS-BPSK fading simulation urgently (2)
matlab code required (3)
help required in matlab code (6)
multipath fading matlab code required (3)
MATLAB code for OFDM required [urgent] (6)
OFDM with QPSK (matlab simulation code required) (6)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS