EGR 103/Fall 2017/Minilab 7
Contents
Clarifications
To mount your CIFS drive on a PC, use the instructions at: Mount your drive via windows.
Troubleshooting
- If you get a broadcast error, it will generally tell you the number of elements in two variables that are different -- look in the variable explorer to figure out what sizes things are (and what they should be)and fix your code. This has most often happened when someone uses the model values to create estimates or vice versa.
- "invalid syntax errors" often happen because the line of code above the one specified have imbalanced parentheses - put the cursor near the last closed parentheses on the line above and see which opener lights up.
- It is generally a bad idea to copy and paste from a PDF -- among other things, you will get the wrong kind of quote (` instead of ') and will need to go back and fix those.
- If there is a complaint about a variable being equal to none, you have likely either called a function without an input argument or you have forgotten to have your function return something.
Typos
- Prior to 6:45am on 12/5/2017, these problems used numbers from a previous edition of the book. This particularly changed the answers to 7.8.3 and 7.8.4. Those have been updated.
- Problem 8.1 in the lab is really 8.2 in the book
7.8.1
Be sure to store your data using code similar to a = np.array([1, 2, 3, 4])
and not just a = [1, 2, 3, 4]
.
Also, to return the result of a long formula, be sure to put the whole thing in parentheses to break it across lines; for instance:
return (1 + 2 + 3 +
4 + 5 + 6 + 7)
For the legend, add labels to each plot command and then call the legend command; for example:
plt.plot(t, x, 'k-', label='position')
plt.plot(t, v, 'r--', label='velocity')
plt.legend()
Partial Answer
St: 5.793e+00
Sr: 7.850e-02
r2: 9.864e-01
The model should be a green dashed line going through the data points.
7.8.2
- Be sure to create a function called
u_y
that returns a value. Also, since the return calculation is long, you will want to put it in parentheses and then on multiple lines, so something like:
def u_y(x):
return ( calculations stuff then
more calculation stuff )
Partial Answer
Root 1: 2.338e+00
Root 2: 7.762e+00
Min of y=-2.086e+01 at x=+1.279e+00
Min of y=-3.274e+01 at x=+8.708e+00
Min of y=-2.086e+01 at x=+1.279e+00
Max of y=+1.953e+02 at x=+5.702e+00
The graph should be like your graph for Lab 5
7.8.3
Partial Answer
(1)
[[ 5 8 15]
[ 8 4 10]
[ 6 0 10]]
(3)
[[ 3 -2 -1]
[-6 0 4]
[-2 0 -2]]
(4)
[[28 21 49]
[ 7 14 49]
[14 0 28]]
(5)
[[3 6 1]]
(6)
[[25 13 74]
[36 25 75]
[28 12 52]]
(7)
[[54 76]
[41 53]
[28 38]]
(8)
[[ 9 2]
[ 4 -1]
[ 3 7]
[-6 5]]
(11)
[[ 66 19 53]
[ 19 29 46]
[ 53 46 109]]
(12)
[[46]]
7.8.4
For complex numbers, write the imaginary part followed directly by a j with no space -- including if you are writing just j. Also, do not put spaces around the + or - between the real and imaginary parts - for instance:
a = 4+1j
Do not use i and do not forget to put the number in front of j, even if that number is a 1.
Partial Answer
8.3:
[[-15.18115942]
[ -7.24637681]
[ -0.14492754]]
8.5:
[[-0.53333333+1.4j ]
[ 1.60000000-0.53333333j]]
7.8.5
Note: when you define your function for curve fitting, the independent variable needs to be the first argument, followed by any constants you are trying to find. Your definition line will likely be something like:
def func(i, p_max, i_sat):
Partial Answer
St: 2.327e+04
Sr: 1.116e+03
r2: 9.520e-01
Coefficients and graph should match your for this lab. Be sure you are using good initial guesses - bad initial guesses will result in a flat red line!