문제

I am doing experiments with different operational amplifier circuits and I need to plot my measured results onto a graph. I have two data sets:

freq1 = [.1 .2 .5 .7 1 3 4 6 10 20 35 45 60 75 90 100]; %kHz
Vo1 = [1.2 1.6 1.2 2 2 2.4 14.8 20.4 26.4 30.4 53.6 68.8 90 114 140 152]; %mV
V1 = 19.6;
Acm = Vo1/(1000*V1);

And:

freq2 = [.1 .5 1 30 60 70 85 100]; %kHz
Vo1 = [3.96 3.96 3.96 3.84 3.86 3.88 3.88 3.88]; %V
V1 = .96;
Ad = Vo1/(2*V1);

(I would show my plots but apparently I need more reps for that)

I need to plot the equation, CMRR vs freq:

CMRR = 20*log10(abs(Ad/Acm)); 

The size of Ad and Acm are different and the frequency points do not match up, but the boundaries of both of these is the same, 100Hz to 100kHz (x-axis). On the line of CMRR, Matlab says that Ad and Acm matrix dimensions do not agree.

How I think I would solve this is using freq1 as the x-axis for CMRR and then taking approximated points from Ad according to the value on freq1. Or I could do function approximations of Ad and Acm and then do the divide operator on those.

I do not know how I would code up this two ideas. Any other ideas would helpful, especially simpler ones.

도움이 되었습니까?

해결책

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:

CMMR

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top