Question: ( b ) [ 1 0 pts . ] Write a Matlab / python code to solve the linear least squares problem. Use (

(b)[10 pts.] Write a Matlab/python code to solve the linear least squares problem. Use \(\mathrm{fib1}\mathrm{~m}/\) fib1.py to generate the true resistances \( R_{i}\) and \( R_{m}\), the voltage inputs \( f \), and the corresponding potentials. Add random noise to the computed potentials to generate the potential measurements using
```
noiselevel =0.05;
error = randn(n,1); error=error/norm(error);
xexp = x.*(1+noiselevel*error);
```
Then set up the linear least squares problem and solve it using the Matlab backslash ('\(\backslash ')\) command to solve the least squares problem.
Print the 'true' resistances that were used to generate the measurements as well as the recovered resistances obtained by solving the linear least squares problem.
Your code should be written for an \( N \) compartment model with arbitrary number of compartments, however, when generating an output please choose a value for \( N \). All output must be organized into a labeled table (this can be Matlab generated or handwritten). For example, if you choose \( N=4\), then your output should look like the following. (Note the X's are where your output would be)
```
input the number of compartments, N: 4
noise level =5.0000e-02
true axial resistance = XXXXX
true membrane resistance = XXXXXX
recovered axial resistance = XXXXXXX
recovered membrane resistance = XXXXXX
```
( b ) [ 1 0 pts . ] Write a Matlab / python code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!