Changes by last author:
Changed:
problem |
Homework assignment |
notation: i1,i2,i3 => o1
0,4,0.1 => 1.1 0,2,0.1 => 1.2 3,4,0.2 => 3.1 1,4,0.3 => 2.1 |
if i1 =0 and i2 = 4 and i3 =0.1 then o1 = 1.1
if i1 =0 and i2 = 2 and i3 =0.1 then o1 = 1.2 if i1 =3 and i2 = 4 and i3 =0.2 then o1 = 3.1 if i1 =1 and i2 = 4 and i3 =0.3 then o1 = 2.1 |
contraint: no DAC or microprocessor. Obviously they want an OPA solution.
That means inputs are weighted. Weight can be negative, actually 2nd weight is negative and exactly -0.05 =(1.1-1.2)/(4-2) as it's obvious from 1st and 2nd line where input vector just differs in 2nd input variable . I expected to find a linear relationship which is damn easy with OPA-s: <code> octave:1> o=[1.1 , 1.2, 3.1, 2.1]; octave:2> x=[0, 4, 0.1; 0,2,0.1; 3,4,0.2; 1,4,0.3]; check only a 3x3 (upper sub-) matrix so inverse can be calculated: octave:3> o1=[1.1 , 1.2, 3.1]; octave:4> x1=[0, 4, 0.1; 0,2,0.1; 3,4,0.2]; a1=inverse(x1) * o1' a1 = 0.233333 -0.050000 13.000000 quick verification with 3d line: octave:13> 3*0.23333 + 4*-0.05 + 0.2*13 ans = 3.1000 OK. Let's see if 4th line also matches: octave:14> 1*0.23333 + 4*-0.05 + 0.3*13 ans = 3.9333 </code> No luck, 3.9333 != 2.1. ---- The trick is to make an additive offset. Step1: find additive offset: output for 0 inputvector 0,0,0 => ? This is done by linearly combining the 4 input vectors. I start it for you, by making first number 0: 0,4,0.1 => 1.1 0,2,0.1 => 1.2 From 3d line we subtract 3*(4th line): 3,4,0.2 => 3.1 -3* 1,4,0.3 => 2.1 =0,-8,-0.7 => -3.2 While from 4th line we subtract 1/3*(3d line): 1,4,0.3 => 2.1 -1/3* 3,4,0.2 => 3.1 =0,...,... => ... Now our equations are: 0,4,0.1 => 1.1 0,2,0.1 => 1.2 0,-8,-0.7 => -3.2 0,...,... => ... Just continue eliminating 2nd and 3d column to get output for 0 input vector. ---- Step2 : subtract the offset from the output Step3 : calculate the a1 weights |
Same as
a1=inverse(x1) * o1' above, that is with matrix inversion. This time you'll see that 4th line will match the weights just fine. |
___
contraints no DAC or microprocessor |