0
$\begingroup$

Lets say I have a Transfer function (H) plot as below. I need to find the SLOPE of the transfer function in dB/MHz.

Digital LPF

That is... i need a plot (db/MHz) vs frequency.

How can i go about it ?

f = 0: 1e6 : 80e6;
H_db=20*log10(abs(H));
s=diff(H_db);
plot(f/1e6,s);

Do i need steps of 1 Mhz .. then its in db/Mhz.. or do i need to divide s with something ?

or am i thinking about this all wrong ?

(update)

Lets say i have a transfer function below:

enter image description here

and then i find the db/mhz vs mhz plot using the following code:

step_size=1e6;
f_H = 0: step_size: fs_ADC+step_size;    % i am using 'f_H' and 'f' since with diff function in the end I am short of one index for ploting.. i hope this is correct
f = 0: step_size: fs_ADC;
H = fir1(f_H); 
H_db=20*log10(abs(H)); 
ss=diff(H_db);  % is this correct ?
plot(f/1e6,ss)

enter image description here

or should i use :

ss=diff(H_db)./diff(f_H);
plot(f/1e6,ss)

Then i get the below figure: .. now i get the 10^-5 on the yaxis.

enter image description here

Please let me know

$\endgroup$
  • 1
    $\begingroup$ Do you know how to find the slope (derivative) or any function? (Rise/Run....) $\endgroup$ – Dan Boschen Jan 14 at 18:21
  • $\begingroup$ Hey Dan, Yeah a general slope formula slope = (diff(y)/diff(x) .. I have used before and its fine.. Its just i am confused about the db/mhz vs mhz plot $\endgroup$ – BandW Jan 15 at 8:51
  • 1
    $\begingroup$ So help me understand where you are confused. What if we substituted "MHz" in you x-axis to "x" and "dB" in your y-axis to "y" (So the starting plot would look the exact same with x going from 0 to 35 and y going from -120 to 0)? Then are you comfortable using the slope formula you gave? That answer of the slope would be y/x. Substitute it back and its dB/MHz. Still confused? Or am I confused by your question? $\endgroup$ – Dan Boschen Jan 15 at 12:03
  • 1
    $\begingroup$ Just think simply for each sample what is the difference in dB (from sample to sample) and divide that by what is the difference in MHz (from sample to sample). Rise over Run. I see in your plot you divide you x-axis by 1e6 which tells me your raw data is actually in units of Hz. so diff(y)/diff(x) would give you dB/Hz, right? If so if you want dB/MHz the multiply that by 1e6 Hz/MHz: dB/Hz * 1e6 Hz/MHz = dB/MHz. Make sense? $\endgroup$ – Dan Boschen Jan 15 at 18:50
  • 1
    $\begingroup$ Thankyou very much Dan.. I think i got it now :) Cheers ! $\endgroup$ – BandW Jan 16 at 12:32
0
$\begingroup$

Okay. I think i got it after some clarification from Dan. Thanks Dan. !

I think what i was confused with was the step size in my frequency vector.. i had thought to have the final result in db/mhz.. the steps should be in 1 Mhz.. but i now realize that the freq vector could be in whatever steps i like but if its in Hz then i need to have my final answer normalized by 1e6 to get from db/Hz --> db/Mhz

So this is the code i finally used..

fs_ADC=200e6;
N=2^11;
step_size=fs_ADC / N ;
f = 0: step_size: fs_ADC;
H = fir1(f);  
H_db=20*log10(abs(H));
slope=1e6*diff(H_db)./diff(f);  % db/Hz--> db/mhz
plot(f(1:end-1)/1e6,slope) 

Figure result till 30 MHz is shown below:

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.