Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB coding, MUST BE; -user-defined Function eg. (res, tol) = Function_name()

ID: 2291294 • Letter: M

Question

MATLAB coding, MUST BE; -user-defined Function eg. (res, tol) = Function_name() -save user inputs eg. Band1 = input() -making a graphical user interface(GUI)

Display options to user (mai Fist try to do it in a single sonpt hen try separating in to a function nd a cript) Save user inputs (main seript Pass values to a function defined Get script done and try GUI at home (extra task) Band Tutor imen Ranhod Make sure you have Bow chart and hand written type in word calcolations for task 1 (jab Include some erunces Include graphs and Image Most important thing is to include answers for reference questions by you (main script es Resistor Colour Code Decoder Do all the calculations in the function (function senipt) e Recall the outputs from function main script) Display resistance (main script Band2

Explanation / Answer

%% Below funtion initially displays the number to be enterd corresponding to the colour band in the resistor

%% based on the number enterd the corresponding position value is calculated

%% the final value returned by the function will be the resistance and tol

function [value, tol] = ResCalc()

%% First band colour

x=input('Enter the first colour band 0.Black 1.Brown 2.Red 3.Orange 4.Yellow 5.Green 6.Blue 7.violet 8.Grey 9. White: ')

%% Since the position is 3rd it is multiplied by 100
value=x*100;
x=input('Enter the second colour band 0.Black 1.Brown 2.Red 3.Orange 4.Yellow 5.Green 6.Blue 7.violet 8.Grey 9. White: ')

%% Second position value is multiplied by the 10 and added to previous value
value=value+x*10;

x=input('Enter the third colour band 0.Black 1.Brown 2.Red 3.Orange 4.Yellow 5.Green 6.Blue 7.violet 8.Grey 9. White: ')

%% Third position value is added directly
value=value+x;

x=input('Enter the fourth colour band 0.Black 1.Brown 2.Red 3.Orange 4.Yellow 5.Green 6.Blue 7.No colour 8.Gold 9. Silver: ')

% Based on the colour this if condition will calculat the power of 10 to be
% multiplied
if x<7
value=value*10^x;
elseif x==7   
value=value*1;
elseif x==8
value=value*0.1;
else
value=value*0.01;
end;

value

x=input('Enter the fifth colour band 1.Gold 2.Silver 3. no colour: ')

if x==1
tol=5
elseif x==2
tol=10
else
tol=0
end