Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

spectrum analysis code in MaTLaB(urgently required)

Status
Not open for further replies.
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
 

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.
 

power spectrum analysis matlab

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

matlab code warped mvdr spectral estimation

amihomo said:
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.
 

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
 

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
 

spectrum analysis with matlab

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

Dave
 

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 !!!!
 

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
 

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 .......
 

spectrum matlab code

My June 11 example runs fine in MATLAB 7.3 on Windows 2000. What versions do you have?

Try this version. It uses simpler functions. You should see a spectrum plot that updates several times per second.
Code:
% Audio spectrum display. To exit, close the figure.
%
fs = 22050;                                 % sample rate, hertz
N = 1024;                                   % duration, samples
window = blackman(N);                       % weighting
window = window / mean(window);             % normalize it
gca;                                        % open the figure
while get(0,'CurrentFigure')                % while figure still open
  y = wavrecord(N, fs);                     % acquire some signal
  h = fft(y .* window);                     % transform
  plot(fs*(0:N/2)/N, 20*log10(max(2/N*abs(h(1:N/2+1)), 1e-10)));
  ylim([-160 20]); xlabel('Hertz'); ylabel('dB');
  drawnow;                                  % allow figure to update
end
 

audio spectrum matlab code

plzzzz tell me i want it urgently............
every code has sum sort of errors lyk
x=x(;
similiarly every code has errors in it !!!!
so plzzzzzz post only those codes which are error free....
 

matlab frequency analysis

Maybe your MATLAB has a problem or is missing an essential feature. The code examples provided by various people generally require the MATLAB Signal Processing Toolbox. Do you have it?

Did you try my recent example above? What happened? What is the answer to the question I asked?

If you had trouble running artsil23's code, then you should have asked him for help back in April.
 

power spectrum analysis in matlab

i have run ur program of 11 june i have told u that i have got the output but its giving me error even after displaying output ..........i m using Matlab7.0
and WINDOWS version is XP .......
and now i have run ur recent code which u have posted on 12th june its simply giving me right answer but not displaying any output.......


now( m file name given by me )

ans =

7.3116e+005







i can either use any input signal from wavread this is what from where i have to take my input signal ........no any connectivity of mic or anything else......simply i have to show output of that signal taken from wavread.......... so tell me the way how i have to do this ........ and output must b in visible form after running this code ........
i will be thankful to u !!!!
and program which artsil23 sent me in april ........
if u make it correct den i will also be thankful to u !!!
u can check by urself by running dat code ......
nyvz simply tell me what changes i have to do in 11 june program that it will not give me same error which i have told u by giving input signal from wavread.....
so paste the whole code .......
i will be very thankful to u !!!!
 

matlab pwelch db

If you type "ver" at the matlab prompt, then you'll get a list of the matlab version you are using and the libraries that are installed. That will help with debugging.

what do you mean when you say this " its simply giving me right answer but not displaying any output.......
"

? How can you get a right answer without displaying any output.

It could also be good to use the clear all command to clear the matlab workspace before you try these matlab scripts.

I just tried this one
Code:
% Audio spectrum display. To exit, close the figure.
%
fs = 22050;                                 % sample rate, hertz
N = 1024;                                   % duration, samples
window = blackman(N);                       % weighting
window = window / mean(window);             % normalize it
gca;                                        % open the figure
while get(0,'CurrentFigure')                % while figure still open
  y = wavrecord(N, fs);                     % acquire some signal
  h = fft(y .* window);                     % transform
  plot(fs*(0:N/2)/N, 20*log10(max(2/N*abs(h(1:N/2+1)), 1e-10)));
  ylim([-160 20]); xlabel('Hertz'); ylabel('dB');
  drawnow;                                  % allow figure to update
end

and it worked OK on my machine, with

Code:
-------------------------------------------------------------------------------------
MATLAB Version 7.0.4.365 (R14) Service Pack 2


Java VM Version: Java 1.5.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
-------------------------------------------------------------------------------------
MATLAB                                                Version 7.0.4      (R14SP2)
Simulink                                              Version 6.2        (R14SP2)
Communications Blockset                               Version 3.1        (R14SP2)
Communications Toolbox                                Version 3.1        (R14SP2)
Control System Toolbox                                Version 6.2        (R14SP2)
Fixed-Point Toolbox                                   Version 1.2        (R14SP2)
Signal Processing Blockset                            Version 6.1        (R14SP2)
Signal Processing Toolbox                             Version 6.3        (R14SP2)
SimPowerSystems                                       Version 4.0.1      (R14SP2)
Simulink Control Design                               Version 1.2        (R14SP2)
Simulink Fixed Point                                  Version 5.1        (R14SP2)
Stateflow                                             Version 6.2        (R14SP2)

as the output of ver


Dave
 

matlab code for bartlett estimator

I don't know why my June 11 code caused a "uimenu" error for you. Just in case you had a really old version of MATLAB, I created the simpler June 12 version. However, your MATLAB 7.0 and WinXP should be fine, unless you don't have the Signal Processing Toolbox.

My June 12 code should never output anything like "ans = 7.3116e+005". Did you modify the code? Please post a copy of the code you are running.

Try copying-and-pasting the code directly from your web browser into the MATLAB Command Window.

artsil23's code is only a partial solution. It does not input from the microphone, and it does not display a spectrum plot.

Try this stripped-down version, just for test purposes. I removed the windowing and loop, so it updates the figure only once.

Code:
% Audio spectrum display
fs = 22050;                                 % sample rate, hertz
N = 1024;                                   % duration, samples
y = wavrecord(N, fs);                       % acquire some signal
h = fft(y);                                 % transform
plot(fs*(0:N/2)/N, 20*log10(max(2/N*abs(h(1:N/2+1)), 1e-10)));
ylim([-160 20]); xlabel('Hertz'); ylabel('dB');
 

matlab program for speech spectrum

i have run these codes sent by dave n echo47
they both r running !!
and the code of 12th june is % 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

answer is
??? Error using ==> uimenu
Invalid object handle.

Error in ==> echo47 at 9
psd(Hs, signal,'Fs',Fs); ylim([-160 0]); % transform and plot
even these errors its showing me an output of spectrum ..
and version is


MATLAB Version 7.0.0.19920 (R14)
MATLAB License Number: 0
Operating System: Microsoft Windows XP Version 5.1 (Build 2600: Service Pack 2)
Java VM Version: Java 1.4.2 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
-------------------------------------------------------------------------------------
MATLAB Version 7.0 (R14)
Simulink Version 6.0 (R14)
Aerospace Blockset Version 1.6 (R14)
Bioinformatics Toolbox Version 1.1 (R14)
CDMA Reference Blockset Version 1.1 (R14)
Communications Blockset Version 3.0 (R14)
Communications Toolbox Version 3.0 (R14)
Control System Toolbox Version 6.0 (R14)
Curve Fitting Toolbox Version 1.1.1 (R14)
Data Acquisition Toolbox Version 2.5 (R14)
Database Toolbox Version 3.0 (R14)
Datafeed Toolbox Version 1.5 (R14)
Dials and Gauges Blockset Version 1.2 (R14)
Embedded Target for Infineon C166 M... Version 1.1 (R14)
Embedded Target for Motorola HC12 Version 1.1 (R14)
Embedded Target for Motorola MPC555 Version 2.0 (R14)
Embedded Target for OSEK VDX Version 1.1 (R14)
Embedded Target for TI C2000 DSP(tm) Version 1.1 (R14)
Embedded Target for TI C6000 DSP(tm) Version 2.1 (R14)
Excel Link Version 2.2 (R14)
Extended Symbolic Math Version 3.1 (R14)
Filter Design HDL Coder Version 1.0 (R14)
Filter Design Toolbox Version 3.0 (R14)
Financial Derivatives Toolbox Version 3.0 (R14)
Financial Time Series Toolbox Version 2.1 (R14)
Financial Toolbox Version 2.4 (R14)
Fixed-Income Toolbox Version 1.0.1 (R14)
Fixed-Point Toolbox Version 1.0 (R14)
Fuzzy Logic Toolbox Version 2.1.3 (R14)
GARCH Toolbox Version 2.0.1 (R14)
Genetic Algorithm Direct Search Too... Version 1.0.1 (R14)
Image Acquisition Toolbox Version 1.5 (R14)
Image Processing Toolbox Version 4.2 (R14)
Instrument Control Toolbox Version 2.0 (R14)
LMI Control Toolbox Version 1.0.9 (R14)
Link for Code Composer Studio® Deve... Version 1.3.1 (R14)
Link for ModelSim Version 1.1.1 (R14)
MATLAB Builder for COM Version 1.1 (R14)
MATLAB Builder for Excel Version 1.2 (R14)
MATLAB Compiler Version 4.0 (R14)
MATLAB Report Generator Version 2.0 (R14)
Mapping Toolbox Version 2.0.2 (R14)
Model Predictive Control Toolbox Version 2.0 (R14)
Model-Based Calibration Toolbox Version 2.1 (R14)
Mu-Analysis and Synthesis Toolbox Version 3.0.8 (R14)
Neural Network Toolbox Version 4.0.3 (R14)
OPC Toolbox Version 1.0 (R14)
Optimization Toolbox Version 3.0 (R14)
Partial Differential Equation Toolbox Version 1.0.5 (R14)
RF Blockset Version 1.0 (R14)
RF Toolbox Version 1.0 (R14)
Real-Time Windows Target Version 2.5 (R14)
Real-Time Workshop Version 6.0 (R14)
Real-Time Workshop Embedded Coder Version 4.0 (R14)
Robust Control Toolbox Version 2.0.10 (R14)
Signal Processing Blockset Version 6.0 (R14)
Signal Processing Toolbox Version 6.2 (R14)
SimMechanics Version 2.2 (R14)
SimPowerSystems Version 3.1 (R14)
Simulink Accelerator Version 6.0 (R14)
Simulink Control Design Version 1.0 (R14)
Simulink Fixed Point Version 5.0 (R14)
Simulink Parameter Estimation Version 1.0 (R14)
Simulink Report Generator Version 2.0 (R14)
Simulink Response Optimization Version 2.0 (R14)
Simulink Verification and Validation Version 1.0 (R14)
Spline Toolbox Version 3.2.1 (R14)
Stateflow Version 6.0 (R14)
Stateflow Coder Version 6.0 (R14)
Statistics Toolbox Version 5.0 (R14)
Symbolic Math Toolbox Version 3.1 (R14)
Virtual Reality Toolbox Version 4.0 (R14)
Wavelet Toolbox Version 3.0 (R14)
xPC Target Version 2.5 (R14)
xPC Target Embedded Option Version 2.5 (R14)

but the last codes r running .......
thanx 4 that codes.....
i m very thankful 2 u !!!



Added after 22 minutes:

but if u will modify that codes as well then it will b ..........
nyvz
would u help me in another task..........
i have been given another project to control parallel port through pc .......
its in harware form
that also controls RPMs and other features of motors....
coding can b in C language, in assembly or control through micro controllers.....
i will be very thanful to u that if ppl u will tell me that which devices i have to connect n IC's and code as well........
in sequence
tell me all dis in sequence .....
i will be very thankful to u for this as well!!!
 

voice spectogram code with matlab

My second code works for you? Ok great!

I don't know why my first code causes "invalid object handle" on your system. It runs fine here. I prefer the second code anyway - it's easier to understand, and it runs faster.

Your question about motor control belongs in a new discussion, not here. You will get better help by asking clear specific questions, instead of a general request for someone to design the entire project for you.
 

spectogram code with matlab

hello Mr DAve and echo47
i have been encountered with a new problem ,that is the codes which u have sent me r running successafully but they r showing me an output of noise .....
i want that it will show output of any wav file by using wavread function and that code also shows output by removing noise in code...
basically wht we have to do is .....
1.show an output spectrum of any wav file
2.by taking any input through function wavread( any wav file )
3.it will remove noise in coding
4.finally the spectrum of that whole wav file will b shown by removing noise in it !!!


note:
i also know that it will not be visible that there's removal of any noise in output but it will be in our code to remove noise .

so kindly ......
i will be very thankful to u !!!!
 

matlab program for using pwelch

please tell me what i have to do ....
i will be very thankful to u !!!
i have already told that what r ammendments required ova dere ........
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top