Rod's Home



ENED 1090: Engineering Models IHomework Assignment #5Due: Week of October 14th beginning of RecitationInstructions: Before you begin editing this document, you must save this document to your laptop or you will end up losing all of your work. If you opened this document directly from Blackboard, click on the Enable Editing button then choose File → Save As and save the document to your laptop. You should set up a folder on your laptop for ENED1090 where you keep all of your homework assignments and lab reports.Show your work! It is fine to work with other students, but what you turn in must be your own work - not something copied from someone else. Problem 1: Do this problem by hand in order to practice for the midterm. OK to double check your answer in MATLAB. What will the two disp statements produce? a = 5; b = 6; c = 3;if a > 3 && c < 7 result = a + b*c;elseif a > 1 && b == 3 result = a*c;elseif b == 5 || c < 5 result = b-15;enddisp(‘result = ‘);disp(result)What will the two disp statements produce? a = 5; b = 6; c = 3;if a > 3 && c < 7 result = a + b*c;endif a > 1 && b == 3 result = a*c;endif b == 5 || c < 5 result = b-15;enddisp(‘result = ‘);disp(result)Explain why the code in part (a) produces a different value for result than the code in part (b)Problem 2: Resistor Value Calculator based on Color Code Figure 1 shows a picture of a resistor as well as the symbol used for a resistor in a circuit diagram.87630045085First DigitSecond DigitPower of 10ToleranceSymbol for Resistor00First DigitSecond DigitPower of 10ToleranceSymbol for ResistorFigure 1: Resistor and Resistor Circuit SymbolThe colored bands on the resistor can be used to identify the resistance. Each color corresponds to a number as shown in the table below.Resistor Color CodeColorBands 1-3Numerical ValueColor for 4th BandToleranceBlack0 Missing20%Brown1 Silver10%Red2 Gold5%Orange3Yellow4Green5Blue6Violet7Gray8White9The nominal value of the resistor can be determined from the color bands on the resistor:Nominal Value of R = (FirstColorValue*10 + SecondColorValue)*10ThirdColorValueThe tolerance indicates how much the actual value of resistance can vary from the nominal value. The manufacturer’s range for the resistor would then be:Range = Nominal Value + Tolerance*Nominal ValueExample: Suppose the color bands on the resistor are YELLOW VIOLET ORANGE GOLD Nominal Value: (4*10 + 7)*103 = 47000 ? = 47 k?Range: 47 + 0.05*47 k? or 44.65 to 49.35 k?. Down-load the m-file Template from the Homework Folder on the Blackboard metasite. Rename the file: HW5_YourLastName. Fill in your name and a description in the comment section at the top of the script. Then add commands to your script file to do the following:Prompt the user for the four colors on the resistor using menu statementsCalculate the nominal value for the resistor and the range of resistanceDisplay (fprintf) the nominal value and range in ohms if the nominal resistance value is smaller than 1000 ?, in kohms if the nominal resistance value is at least 1000 ? but less than 1,000,000 ? and in Mohms if the nominal resistance value is 1,000,000 ? or higher. Make sure to include units in your fprintf statements. Display two places behind the decimal point for range. Display zero places behind the decimal point if the resistance is in ? and display one place behind the decimal point if the resistance is in k? or M?Test your script file using the YELLOW VIOLET ORANGE GOLD example from the previous page to make sure your program is working properly.Note: submit your script file along with this HW assignmentRun your script for the three cases shown in the table below and paste the output in the MATLAB Command window below the table. Color Band 1Color Band 2Color Band 3Tolerance BandGrayBrownBlackNoneGreenBlueRedSilverOrangeOrangeBlueGoldScript Output for: Gray-Brown-Black-NoneScript Output for: Green-Blue-Red-Silver Script Output for: Orange-Orange-Blue-Gold Remember: Submit your script file along with this HW assignment. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download