I would use union
to get a uniform frequency axis and then use interp1
to interpolate the data points. We need to heed Martin's advice and use the ./
operator for element by element operations. Here's an example:
Acm = Vo1./(1000*V1);
Ad = Vo1./(2*V1);
freq = union(freq1,freq2)
Acmi = interp1(freq1,Acm,freq);
Adi = interp1(freq2,Ad,freq);
% test the goodness of the interpolation
figure; plot( freq1, Acm, freq, Acmi );
legend('origial A_{cm}', 'interolated A_{cm}','Location','NorthWest');
figure; plot( freq2, Ad, freq, Adi );
legend('origial A_{d}', 'interolated A_{d}');
Then plot the output:
CMRR = 20*log10(abs(Adi./Acmi));
plot( freq, CMRR )
title('Common Mode Rejection Ratio')
xlabel('Frequency(Hz)')
ylabel('CMMR (dB)')
Here's my final plot: