MATLAB QUESTION
A voltage divider has output voltage vo given by R. R+R2 where v, is the input voltage and R, R2 are the resistor values. However, components have a tolerance so the actual value can be anything within the tolerance limits. Calculating the range of possible output voltages will help in selecting an appropriate tolerance for the components. Write a MATLAB script to compute the minimum and maximum output voltages. The script should prompt the user to enter the values of v, R1, R2, and the tolerance, tol (in percent). Hint: minimum voltage occurs when R, is largest and R2 is smallest; maximum voltage is the opposite case. Comments may be omitted. Here is an example of the script being used (your output may be formatted differently): > voltagedivider Enter input voltage (volts): 12 Enter R1 (ohms): 100 Enter R2 (ohms): 220 Enter tolerance (%): 5 The output voltage will be between 7.987 V and 8.503v. s shown in the For the demonstration you will enter the \"clear\" command then use the script a examples above. Each demonstration will be evaluated. Test your script and make sure it works
%Input data
Vi=input(\'Enter input voltage (Volts): \');
R1=input(\'Enter R1 (ohms): \');
R2=input(\'Enter R2 (ohms): \');
tol=input(\'Enter tolerance (%): \');
%Minimum output voltage
R1_max=R1*(1+tol/100);
R2_min=R2*(1-tol/100);
Vo_min=vi*R2_min/(R1_max+R2_min);
%Maximum output voltage
R1_min=R1*(1-tol/100);
R2_max=R2*(1+tol/100);
Vo_max=vi*R2_max/(R1_min+R2_max);
%Output
fprintf(\'The output voltage will be between %1.3f and %1.3f\', Vo_min, Vo_max);