Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer this correctly MATLAB grader problem: HW5_2 Given the circuit shown at right. Using Kirchoff's voltage law, the following equations are obtained: -V+ R,L

please answer this correctly image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
MATLAB grader problem: HW5_2 Given the circuit shown at right. Using Kirchoff's voltage law, the following equations are obtained: -V+ R,L + Raid = 0 -RoleRuiz + Rsis = 0 -Rois + Ruiz + V2 = 0 Then, by conservation of charge 1 = 12 +14 12 = 1 + is We now have five equations to solve for the five currents Let v =100 and V=50. Write a function M-file that takes as input 5 resistors in an array and returns the 5 currents in an array as output. Your code should be placing the equations in matrix form and using the backslash to solve. For example: >> R-15 100 200 150 250) * 1000 kOhm >> curr - LoopCurrent (R) ans- 1.0-03 0.9544 0.3195 0.0664 0.6349 0.2531 Five curients in a circuit 6 solutions submitted (max: Unlimited) currents Function 2/ function curr - LoopCurrent(R) five currents in a circuit /3/% curry - YoopCurrent(R) % INPUT: R- array of five resistors 5 % OUTPUT: curr- five currents in the loops in the circuit end Code to call your function des Liks integration RY Documentation Test Code: XLoobcentTestSuite (s temps) 2/ import the base case & line processing if needed Xxarhin:'off', 'MATLAS:dispatcher:nameConflict') 4 Xulwrite('https://dl.dropboxusercontent.com/u/46569687/ProcessLine.pl Xidpath('.) 16 . Atesy Tase/ 8/R-15 16e 200 150 250) 1000; XkOhm sudedt-LoopCurrent(); 16 fefryference. LoopCurrent(R) 11 assert(isequal(round(student, 4), round(ref, 4)), 'Please check assignment for correct values) Test 2 (Prelyst) Test Code: 1 different case, yet the same 2 -15 150 250 100 2001" 1000; xkohm 3 /student-LoopCurrent(R): 4 ref-reference. LoopCurrent(); assert(isequal(round(student, 4), round(ref. 4)), 'Failed R-5 150 250 100 2001 1000; xkon. Some is as sample case, but different ord Test 3 (Pretest) Test Code: 1 different altogether 2 R-10 210 140 230 3001; student-LoopCurrent(R): 4 ref-reference. LoopCurrent(); assert (isequal(round(student, 4), round(ref, 4)). Falled -10 210 140 230 300) curr-0.6045, 0.1900, 0.0200. 0.4035, 0.1760) Test 8 (Pretest) Test Code Sohe/mofe case, equal resistors A P-[Be s 80 80 80]; student-LoopCurpent(R); ref=reference roopCurrent(); s assertta sequl(round(student, 4), round(ref,4)), 'Failed E-[82 se sa se 80). All reista Test 5 (Pretest) Test Code: 1% solving criteria 2 found_inv-e;found slash-e: 3 fid - fopen('LoopCurrent.m'); 4 While (feof(fid)) Eget next line & remove whitespace, comments, text strings %s - ProcessLine(fid); 5 - fgetl(fid); Xget the next line in the code while -isempty(s) && $(1) == '*'; S = fgetl(fid); end Xremove comment line 5 - strtok(s,'*'); remove comments in - strfind(s,'inv('); in2 - strfind(s,''); if -isempty(in) Xhave to test once we find it isn't empty found_iny - found inv + 1; Xcount occurances end if -isempty(in2) found_slash - found slash+1; end 21 end 23 fclose(fid): 24 assert(found in 'Code should not include iny. Use backslash to solve) assert(ound slash-. Code should include backslash Don e by hand Ich O RI 9 Test 6 (Pretest) Test Code: 1 Xwarnings 2 warns - checkcode('LoopCurrent.m','-string"); %check the M-file for warnings 3 ini-strfind (warns, 'Terminate statement with semicolon'); 4 in3-strfind(warns, "might not be aligned with its matching' ); 5 assert(isempty(ini), 'All assignment statements should have a semicolon") assert(isempty(in3), 'Make sure if, for & while structures line up with their "end"s') MATLAB grader problem: HW5_2 Given the circuit shown at right. Using Kirchoff's voltage law, the following equations are obtained: -V+ R,L + Raid = 0 -RoleRuiz + Rsis = 0 -Rois + Ruiz + V2 = 0 Then, by conservation of charge 1 = 12 +14 12 = 1 + is We now have five equations to solve for the five currents Let v =100 and V=50. Write a function M-file that takes as input 5 resistors in an array and returns the 5 currents in an array as output. Your code should be placing the equations in matrix form and using the backslash to solve. For example: >> R-15 100 200 150 250) * 1000 kOhm >> curr - LoopCurrent (R) ans- 1.0-03 0.9544 0.3195 0.0664 0.6349 0.2531 Five curients in a circuit 6 solutions submitted (max: Unlimited) currents Function 2/ function curr - LoopCurrent(R) five currents in a circuit /3/% curry - YoopCurrent(R) % INPUT: R- array of five resistors 5 % OUTPUT: curr- five currents in the loops in the circuit end Code to call your function des Liks integration RY Documentation Test Code: XLoobcentTestSuite (s temps) 2/ import the base case & line processing if needed Xxarhin:'off', 'MATLAS:dispatcher:nameConflict') 4 Xulwrite('https://dl.dropboxusercontent.com/u/46569687/ProcessLine.pl Xidpath('.) 16 . Atesy Tase/ 8/R-15 16e 200 150 250) 1000; XkOhm sudedt-LoopCurrent(); 16 fefryference. LoopCurrent(R) 11 assert(isequal(round(student, 4), round(ref, 4)), 'Please check assignment for correct values) Test 2 (Prelyst) Test Code: 1 different case, yet the same 2 -15 150 250 100 2001" 1000; xkohm 3 /student-LoopCurrent(R): 4 ref-reference. LoopCurrent(); assert(isequal(round(student, 4), round(ref. 4)), 'Failed R-5 150 250 100 2001 1000; xkon. Some is as sample case, but different ord Test 3 (Pretest) Test Code: 1 different altogether 2 R-10 210 140 230 3001; student-LoopCurrent(R): 4 ref-reference. LoopCurrent(); assert (isequal(round(student, 4), round(ref, 4)). Falled -10 210 140 230 300) curr-0.6045, 0.1900, 0.0200. 0.4035, 0.1760) Test 8 (Pretest) Test Code Sohe/mofe case, equal resistors A P-[Be s 80 80 80]; student-LoopCurpent(R); ref=reference roopCurrent(); s assertta sequl(round(student, 4), round(ref,4)), 'Failed E-[82 se sa se 80). All reista Test 5 (Pretest) Test Code: 1% solving criteria 2 found_inv-e;found slash-e: 3 fid - fopen('LoopCurrent.m'); 4 While (feof(fid)) Eget next line & remove whitespace, comments, text strings %s - ProcessLine(fid); 5 - fgetl(fid); Xget the next line in the code while -isempty(s) && $(1) == '*'; S = fgetl(fid); end Xremove comment line 5 - strtok(s,'*'); remove comments in - strfind(s,'inv('); in2 - strfind(s,''); if -isempty(in) Xhave to test once we find it isn't empty found_iny - found inv + 1; Xcount occurances end if -isempty(in2) found_slash - found slash+1; end 21 end 23 fclose(fid): 24 assert(found in 'Code should not include iny. Use backslash to solve) assert(ound slash-. Code should include backslash Don e by hand Ich O RI 9 Test 6 (Pretest) Test Code: 1 Xwarnings 2 warns - checkcode('LoopCurrent.m','-string"); %check the M-file for warnings 3 ini-strfind (warns, 'Terminate statement with semicolon'); 4 in3-strfind(warns, "might not be aligned with its matching' ); 5 assert(isempty(ini), 'All assignment statements should have a semicolon") assert(isempty(in3), 'Make sure if, for & while structures line up with their "end"s')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions