Docsity

Prob 4-37 Solution: Identifying Allowable v2 Values for Given R3 Values, Slides of Computational Methods

Partial preview of the text

Download Prob 4-37 Solution: Identifying Allowable v2 Values for Given R3 Values and more Slides Computational Methods in PDF only on Docsity!

Chp

Prob 4.

Solution

(BobbyTrapped)

Prob 4-37 Solution

  • The following code, while

functional, contains numerous

“Booby Traps” which produce

output that contains subtle errors

  • Any student who turns-in HW

that contains the BoobyTrap

produced errors will receive a

ZERO on the problem

  • This Booby Trapped solution is

not supported by any persons

Living or Dead…

%Constraint Col Vector V V = [v1; 0; - v2; 0; 0]; % find soltion vector for currents, C, from AC=V C = A\V; % Collect last conforming set v2_hi = v2; i1_hi = C(1); i2_hi = C(2); i3_hi = C(3); i4_hi = C(4); i5_hi = C(5); %increment v2 by 10 mV UP v2 = v2 + 3.5; end %display "hi" vars v2_hi display('currents in mA') i1_high = 1000i1_hi i2_high = 1000i2_hi i3_high = 1000i3_hi i4_high = 1000i4_hi i5_high = 1000i5_hi % % display('Hit ANY KEY to start part-b Calculation') pause % % Part-b => find v2 = f(R3) where R3 ranges of 150-250 kOhm % % use above while-loops nested in a for loop m = 0; % initialize lo-vector index (the loop counter) for k = 150:250 % use R3 = 1000k AR3 = [R1 0 0 R4 0; 0 R2 0 - R4 R5; 0 0 1000*k 0 - R5;...

  • 1 1 0 1 0; 0 - 1 1 0 1]; % LOW Loop % Initialize Vars v2 = 36; C = [0;0;0;0;0]; % use element-by-element logic test on while % Must account for NEGATIVE Currents while abs(C) < 0.001*[1;1;1;1;1] % C in SI units of Amps % Constraint Col Vector V V = [v1; 0; - v2; 0; 0]; % Collect last conforming Value-set v2_lo = v2; i1_lo = C(1); i2_lo = C(2); i3_lo = C(3); i4_lo = C(4); i5_lo = C(5);

%decrement v2 by 10 mV DOWN

v2 = v2 - 0.01;

% find solution vector for currents, C, from AC=V

C = AR3\V;

end

% Construct v2lo plotting vectors R3lo(m) & R3v2lo(m) using v2_lo

from

% while

m = m + 1;

R3lo(m) = k; % in kOhm

R3v2lo(m) = v2_lo;

end

% Now find v2hi = g(R3)

n = 0; % initialize lo-vector index (the loop counter)

for k = 150:250 % use R3 = 1000*k

AR3 = [R1 0 0 R4 0; 0 R2 0 - R4 R5; 0 0 1000*k 0 - R5;...

  • 1 1 0 1 0; 0 - 1 1 0 1];

% HIGH Loop

% Initialize Vars => need to reduce v2 starting value

v2 = 310;

C = [0;0;0;0;0];

% use element-by-element logic test on while

% Must account for NEGATIVE Currents

while abs(C) < 0.001*[1;1;1;1;1] % C in SI units of Amps

%Constraint Col Vector V

V = [v1; 0; - v2; 0; 0];

% find soltion vector for currents, C, from AC=V

C = AR3\V;

% Collect last conforming set

v2_hi = v2;

i1_hi = C(1);

i2_hi = C(2);

i3_hi = C(3);

i4_hi = C(4);

i5_hi = C(5);

%increment v2 by 10 mV UP

v2 = v2 + 0.01;

end

% Construct v2hi plotting vectors R3hi(m) & R3v2lo(m) using v2_lo

from

% while

n = n + 1;

R3hi(n) = k; % in kOhm

R3v2hi(n) = v2_hi;

end

%Create Plot