You are on page 1of 2

rf=1; % declare data

r1=1;
r2=2;
r3=4;
r4=8;

v1=5; % declare data for first case


v2=0;
v3=0;
v4=5;
vout1=-rf*(v1/r1+v2/r2+v3/r3+v4/r4); % calculate output voltage for first case
using formula
disp(['The output voltage for first case is ' num2str(vout1)]); % check result
The output voltage for first case is -5.625

v1=0; % declare data for second case


v2=5;
v3=5;
v4=0;
vout2=-rf*(v1/r1+v2/r2+v3/r3+v4/r4); % calculate output voltage for second case
disp(['The output voltage for second case is ' num2str(vout2)]); % check result
The output voltage for second case is -3.75

v1=5; % declare data for third case


v2=0;
v3=5;
v4=0;
vout3=-rf*(v1/r1+v2/r2+v3/r3+v4/r4); % calculate output voltage for third case
disp(['The output voltage for third case is ' num2str(vout3)]); % check result
The output voltage for third case is -6.25

disp(['The output voltage for first case is ' num2str(vout1) 'V']); % final answer
for first case
The output voltage for first case is -5.625V

disp(['The output voltage for second case is ' num2str(vout2) 'V']); % final
answer for second case
The output voltage for second case is -3.75V

disp(['The output voltage for third case is ' num2str(vout3) 'V']); % final answer
for third case
The output voltage for third case is -6.25V

You might also like