0

I am producing this graph (reduced code version) :

k = 1000
r = [100 220 470 1*k 2200 4700 10*k 22*k 47*k 100*k 220*k 470*k 1000*k ]

unModNB = [0.72 0.746 0.801 0.92 1.16 1.69 2.78 4.6 6.45 9.1 11.2 12.4 13.2]
unModWB = [1.124 1.17 1.23 1.48 1.84 2.65 4.2 7.6 11.8 15.4 18.6 20.01 21.7]

ModNBdB = 20*log10( ModNB)
ModWBdB = 20*log10( ModWB)

semilogx( r,  ModNBdB, r, ModWBdB )
grid
legend(Line 1 ', 'Line 2')

How am I able to produce another graph of the delta between line 1 and line 2 across intervals of delta across the full scale?

I want to avoid simply using the reading deltas because of the 'jumpy' graph that this meathod generates.

Many many thanks for any help,

Ed.

1 Answers1

0

I believe what you want to do is interpolate between the unModNB and unModWB points and calculate the differences (deltas, as you say) between those. For that you can use interp1(). Try this:

k = 1000;
r = [100 220 470 1*k 2200 4700 10*k 22*k 47*k 100*k 220*k 470*k 1000*k ];

unModNB = [0.72 0.746 0.801 0.92 1.16 1.69 2.78 4.6 6.45 9.1 11.2 12.4 13.2];
unModWB = [1.124 1.17 1.23 1.48 1.84 2.65 4.2 7.6 11.8 15.4 18.6 20.01 21.7];

ModNBdB = 20*log10( unModNB );
ModWBdB = 20*log10( unModWB );

semilogx( r, ModNBdB, r, ModWBdB )
grid
legend('Line 1', 'Line 2')

sampled_x_vals = linspace(r(1),r(end),1000);

unModNB_sampled = interp1(r, unModNB, sampled_x_vals, 'pchip');
unModWB_sampled = interp1(r, unModWB, sampled_x_vals, 'pchip');

deltas = unModWB_sampled-unModNB_sampled;
figure, semilogx(sampled_x_vals,deltas), grid;

If, by 'deltas' you mean something other than difference, please clarify.

Chuck
  • 86
  • 6
  • Awesome, I will give that a try when I get back to that. By delta I did indeed mean the difference between the two lines, I intended the phrasing to make it clear that I whished to do whilst, as you have educated me, interpolating. Many thanks, I will look into understanding what you have done and implementing it in a few hours, will be back to up rep! – Edward Prentice May 11 '14 at 14:12
  • I have examined your code and understand it I think, but was not expecting it to produce what it did. The graph my code generates has a difference of roughly 4 between the plotted lines at r = 10^2. The plot your code generates begins at roughly 0.4. By the end it appears to be correct. Could this be because of an incorrect form of interpolation ? – Edward Prentice May 11 '14 at 18:41