{"id":69325,"date":"2021-11-01T20:03:18","date_gmt":"2021-11-01T20:03:18","guid":{"rendered":"https:\/\/papersspot.com\/blog\/2021\/11\/01\/user-defined-functions\/"},"modified":"2021-11-01T20:03:18","modified_gmt":"2021-11-01T20:03:18","slug":"user-defined-functions","status":"publish","type":"post","link":"https:\/\/papersspot.com\/blog\/2021\/11\/01\/user-defined-functions\/","title":{"rendered":"User-Defined Functions"},"content":{"rendered":"<p>INTRODUCTION <br \/>The purpose of this lab is to practice defining and using your own functions in MATLAB. For this exercise, we will be writing a circuit solver for three resistors in series: <\/p>\n<p>Figure 1. Series Resistive Circuit <br \/>and three resistors in parallel: <\/p>\n<p>Figure 2. Parallel Resistive Circuit <br \/>PROCEDURE <br \/>As usual, include a comment at the top explaining the purpose of the script, your name, and the date it was created. <br \/>Create a main script called main.m. In this script, you will be:Creating three variables for three resistance values and a variable for the voltage source value. Be sure your variable names reflect what the variable is storing. <br \/>Calling functions and storing output for computing the series and parallel equivalent resistances, and power. <br \/>Communicating with the user. <\/p>\n<p>Create a function that computes the equivalent resistance for resistors in series. The function should take in as input the three resistance variables you defined in your main function and it should return as output the equivalent resistance. For series resistors, equivalent resistance is: <br \/>EquivalentResistance=R1 R2 R3&#8230;EquivalentResistance=R1 R2 R3&#8230; <br \/>3. Create a second function that computes the equivalent resistance for resistors in parallel. The function should take in as input the three resistance variables you defined in your main function and it should return as output the equivalent resistance. For parallel resistors, equivalent resistance is: <br \/>EquivalentResistance=11R1 1R2 1R3&#8230;EquivalentResistance=11R1 1R2 1R3&#8230; <br \/>4. Create a third function that computes current and power delivered by the voltage source. Your function should take in as input the equivalent resistance and return two outputs, current and power. Let equivalent resistance be denoted Req, then, current and power are: <br \/>Current=VoltageReqCurrent=VoltageReq <br \/>Power=Current\u22c5VoltagePower=Current\u22c5Voltage <br \/>5. Run two cases of your code and report to the user the results of your calculations. The test cases are: <br \/>Test Case 1: R1 = 120 Ohms, R2 = 230 Ohms and R3 = 250 Ohms. Voltage source = 10V. <br \/>Test Case 2: R1 = 25 Ohms, R2 = 70 Ohms and R3 = 100 Ohms. Voltage source = 9V. <br \/>Your communication should follow the format: <br \/>&#8220;For resistances 100 Ohm, 200 Ohm and 300 Ohms, the equivalent resistance in series is 600 Ohms.&#8221; <br \/>&#8220;For a 12V voltage source, the source current supplied is .02 Amps and the power supplied is .24 Watts.&#8221; <br \/>&#8220;For resistances 100 Ohm, 200 Ohm and 300 Ohms, the equivalent resistance in parallel is 54.545454 Ohms.&#8221; <br \/>&#8220;For a 12V voltage source, the source current supplied is .22 Amps and the power supplied is 2.64 Watts.&#8221; <br \/>TURN-IN INSTRUCTIONS <br \/>You will need to submit .m files for each function you define. Each .m file should include your name and function description in comments. Upload your files via Canvas. Let me know if you have any questions! <br \/>RubricCriteriaRatingsPtsThis criterion is linked to a Learning OutcomeFunctionality <br \/>10 ptsExcellent <br \/>The code runs as expected, with maybe 1 minor mistake <br \/>8 ptsGood <br \/>The code runs well in general, but there are several minor mistakes or maybe 1 major mistake <br \/>5 ptsSolid Attempt <br \/>The code runs, but there are MANY major mistakes and\/or minor mistakes. <br \/>0 ptsChaos <br \/>The code does not run and\/or does not approach the intended functionality of the lab <br \/>10 pts <br \/>This criterion is linked to a Learning OutcomeCode Comments <br \/>5 ptsExcellent <br \/>The code is properly commented so another engineer may review the code, understand its\u2019 functionality, and use the code. <br \/>4 ptsGood <br \/>Most of the code is properly commented so another engineer may review the code, understand its\u2019 functionality, and use the code <br \/>2.5 ptsSolid Attempt <br \/>More than half the code is commented, but comments are not clear and\/or do not reflect functionality. <br \/>0 ptsChaos <br \/>Less than half the code is commented <br \/>5 pts <br \/>This criterion is linked to a Learning OutcomeCode structure <br \/>5 ptsExcellent <br \/>The code structure uses the recently covered materials in the reading and classroom to efficiently provide functionality <br \/>4 ptsGood <br \/>The code structure MOSTLY uses the recently covered materials in the reading and classroom to efficiently provide functionality <br \/>2.5 ptsSolid Attempt <br \/>The code structure works by any means to provide functionality <br \/>0 ptsChaos <br \/>There is no functionality and therefore no code structure <br \/>5 pts <br \/>Total Points: 20 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>INTRODUCTION The purpose of this lab is to practice defining and using your own functions in MATLAB. For this exercise, we will be writing a circuit solver for three resistors in series: Figure 1. Series Resistive Circuit and three resistors in parallel: Figure 2. Parallel Resistive Circuit PROCEDURE As usual, include a comment at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[33],"class_list":["post-69325","post","type-post","status-publish","format-standard","hentry","category-research-paper-writing","tag-mathematics"],"_links":{"self":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/69325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/comments?post=69325"}],"version-history":[{"count":0,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/69325\/revisions"}],"wp:attachment":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/media?parent=69325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/categories?post=69325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/tags?post=69325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}