In: Electrical Engineering
3. Use matlab to plot the output voltage of an inverting operational amplifier given the following conditions: K = Gain of the amplifier = 12.5. Vi = input voltage -2.5 < Vi < 2.5 V], (use 0.25 increments). V+ = positive power supply voltage, V+ = +20 V. V- = negative power supply voltage V- = -20V. Vo = output voltage Vo = -KVi Recall that if the output voltage Vo is greater than V+, or less than V-, the output voltage Vo gets clipped to the V+, or V- voltage, (clipped at the rail voltage).
K=12.5; % gain of the amplifier
Vp=+20; % Positive power supply
Vn=-20; % Negative power supply
i=0;
Vout=[];Vin=[]; % initiating input and output voltage
for Vi=-2.25:0.25:2.25; % input voltage staring from -12.5V to
+12.5V
i=i+1;
V=-K*Vi; % inverting opAmp ouput voltage equation
if V>Vp
V=Vp; % if the output greaterthan positive power
% supply then it become positive power supply
elseif V<Vn
V=Vn; % if the output greaterthan Negative power
% supply then it become Negative power supply
end
Vout(i)=V; % Storing each output voltage value in an array
Vin(i)=Vi; % Storing each input voltage value in an array
end
figure;
% Plotting the Vout vs Vin of inverting opamp circuit
plot(Vin,Vout,'-ro','linewidth',2);grid on;grid minor;
xlabel('V_{in}');ylabel('V_{out}');
title('Inverting Operational Amplifier output for Gain K =
12.5');