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.

Anyone knows what this matalb code lines tells

Status
Not open for further replies.

vjfaisal

Full Member level 4
Full Member level 4
Joined
Sep 24, 2006
Messages
205
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
pakistan
Activity points
2,701
hi,
please help me in these statements (1) , ( 2 ), ( 3 ) only ,
if anyone knows this...........


N = 512;
dt = 1/fs; %sampling time
T = 1;
t = 0:dt:1;
y=textread('......txt');
Y = fft(y,N);
Pyy = 2*abs(Y) / min(N,T/dt); ( 1 )
mag1 = 20*log10(abs(Pyy)); ( 2 )
f = 1/dt*(0:N/2)/N;
figure(1);
plot(y)

figure(2);
plot(f,mag1(1:N/2+1)); ( 3 )

i wan to know that what these statement tells .... plz briefly explain me

best regards
 

vjfaisal said:
hi,
please help me in these statements (1) , ( 2 ), ( 3 ) only ,
if anyone knows this...........


N = 512;
dt = 1/fs; %sampling time
T = 1;
t = 0:dt:1;
y=textread('......txt');
Y = fft(y,N);
Pyy = 2*abs(Y) / min(N,T/dt); ( 1 )
mag1 = 20*log10(abs(Pyy)); ( 2 )
f = 1/dt*(0:N/2)/N;
figure(1);
plot(y)

figure(2);
plot(f,mag1(1:N/2+1)); ( 3 )

i wan to know that what these statement tells .... plz briefly explain me

best regards
(2) convert magnitude to dB unit
(3) plot the response of magnitude-to-frequency
 

1) First, you choose the dimension of Fast Fourier Transform (number of frquency samples (number of bins)) - N.

2) fs - sampling frequency, which is considered to be known (otherwise you should define it's value)

3) Then you compute the sampling period dt, which is opposite to the sampling frequency. dt = 1/fs

4) Then you introduce the time vector t (normalized time vector), with the step, equal to the sampling period

5) After this, you download the txt file, using the function textread and write the loaded information in the corresponding variable.

6) After this, you compute the FFT of y (fft of signal) with a preliminary defined dimension

7) Then you getb the expression of the discrete-time signal's spectrum from it's frequency bins, counted by fft - the expression for PSD of discrete-time signal

8) The you convert the values in db in order to plot on semilogarithmic scale on the y-axis (it's often more convenient to study the spectrum, when it's depicted in db. Sometimes, frequency is simultaneously plot in logarithmic scale too)

9) The you plot the half-spectrum, because it's symmetric, therefore there is no use in plotting the entire spectrogram

With respect,

Dmitrij
 

hi
please help me in above lines of code......

Q: Why we need Time vector iin Above code or usually when we could use it.

Q: Y = fft(y,N);
Pyy = 2*abs(Y) / min(N,T/dt);
mag1 = 20*log10(abs(Pyy));


From these lines, when we take FFt only gives us a plane , then this code tells in Pyy? what this line tells..

Q: After Absolute value , why we need to calculate magnitude.

please help me in these lines....

best regards
 

Q: Why we need Time vector iin Above code or usually when we could use it.

A: Because time vector allows to plot signal in the Figure with defined scale on time-axis, besides, every sample of signal has its unique time location

__________________________________________________________________

Q: After Absolute value , why we need to calculate magnitude.

A: Magnitude defines the amplitude Fourier spectrum in semilogarithmic scale (as I've written above, in the 1st message). It's very convenient when the range of amplitudes is too large or when you want to zoom the domains near the small amplitudes.

With respect,

Dmitrij
 

    vjfaisal

    Points: 2
    Helpful Answer Positive Rating
hi

i m cofused in some Question as in previous post , yet not cleared....
i m posting some of my results(pics) of the above code , plz try download it and try to explain me from these ........

1) first the original signal in text form ,i read it in matlab
2) The FFt of the origial signal ( This gives a complex plane)
3) why we need Absolute of the FFT .

Q1. please see in pic , that taking absolute gives us replica after the samples of 240 (half) . what does this means......
Q2. after taking absolute, we take magnitude? what difference could be analyse in both these? please explain it complete.

Q3: also tell what is the difference between in N samples ( 512, 4096,e.t.c),
and n , in filtertering for.e.g [n,wn,beta,type]=kaiserord(fc,a,dev,Fs), and 'n' in the above example.

please help me in these question, detailed........

best regard
 

The fft() returns an array of complex values. A complex value tells you magnitude and phase. The abs() function extracts the magnitude (amplitude) and discards the phase. That's what you want for an ordinary spectrum plot.

If you wish to display the magnitude in decibels rather than linear units, then you can calculate dB=20*log10(magnitude). A decibel is a ratio, so you may need to include a scaling factor, depending on your desired display units.

If your input signal is real (not complex) then it contains identical positive and negative frequencies. An FFT normally shows you both sides. Many folks simply discard the duplicate negative side when plotting. If your input signal is complex, then it probably has unequal positive and negative sides.

"N samples" probably refers to the number of samples in your data. The "n" returned by kaiserord() is the order of the Kaiser function that meets certain requirements. They are unrelated concepts. See kaiserord documentation for more info. I don't see any 'n' in your above example.

Elsewhere you asked, "please also give me the concept of why frequency domain plots in -fs/2 to fs/2 or 0 to fs/2 range". A sampled baseband signal (let's ignore bandpass sampling for now) contains frequencies that are no greater than half the sample rate. That's basically the Nyquist sampling theorem.
 

    vjfaisal

    Points: 2
    Helpful Answer Positive Rating
hi
i have following question related to FIlters, if anyone knows ,please help me....

Q1: WHy and How the concept of Extremal Frequencies Arise in optimal (Equiripple) technique, as there is no such concepts in Windows and frequency response technique ??

Q2:
What is remez exchange algorithm ( uuse in Equiripple technique) basics or FOrmula or End results ??

Q3: Are all the FIR filters (kaiser , Equiripple e.t.c ) are in time domain or frequency domain ??

best regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top