Question: NOTE: We do not normally assign an fprintf to a variable. However, here we need to in order for Matlab Grader to grade your work
NOTE: We do not normally assign an fprintf to a variable. However, here we need to in order for Matlab Grader to grade your work and compare your answer to the solution. For the purposes of this class, please do not assign fprintf commands to variables outside of Matlab Grader. Code has already been provided to define the following variables:
ResistorValues is a ten element row vector that contains the resistance values of ten resistors with integer values randomly assigned between and ohms.
SeriesorParallel is a character vector that is equal to S to indicate a series connection, P to indicate a parallel connection, or a different erroneous value, A
Add code below what is already provided to use the appropriate formula as described above to compute the equivalent resistance of a simple resistive circuit consisting of only seriesconnected or parallelconnected resistors. Your code should compute a scalar value that is the equivalent resistance of the circuit and assign that value to the variable EquivResistance.
At the end of your code, please use the fprintf command to output the equivalent resistance. Assign the fprintf to the variable outputresist. The fprintf text must be as follows: 'The equivalent resistance is XXX ohms. where XXX represents the integer value of the equivalent resistance. Please be sure to include the period at the end and no
Do not use any special formatting operators. Only use the and the conversion character in place of the XXX
Use a switchcaseotherwiseend structure in your solution.
Do not overwrite SeriesorParallel or ResistorValues in your code. If the entered is erroneous, please assign a value of to EquivResistance and use disp to output that there was 'Invalid Input.
ResistorValues randi;
dispThe resistor values are:
dispResistorValues This is just for your knowledge as a check when testing
pickOne randi;
if pickOne
SeriesorParallel S; for series
dispThe circuit's resistors are connected in series. for your knowledge when testing
elseif pickOne
SeriesorParallel P; for parallel
dispThe circuit's resistors are connected in parallel. for your knowledge when testing
else
SeriesorParallel A; for an erroneous value
dispAn erroneous value was entered. for your knowledge when testing
end
Enter the code to solve the problme below this line.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
