Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In MATLAB how do I.... 1. Download the data file, lab7 data.mat, to Matlab’s wor

ID: 3576236 • Letter: I

Question

In MATLAB how do I....

1. Download the data file, lab7 data.mat, to Matlab’s working directory and read it into Matlab using the load command:

Use the whos command to examine your workspace: you should see two vectors, V and Fv. The vector V contains voltage values, in units of mV; the vector Fv contains the left-hand side of Eqn. (2) that were measured at the same times. Use the size command to print the dimensions of V and Fv to your diary.

2. Use the normal equations (AT Axˆ = AT b) to fit the data to a line: i.e. find C, D such that F(V) = C+DV (3)

Print C and D to your diary.

Your fitted curve, C + DV , will not exactly go through all of the data points. Report the

average error as follows:

Here yLin is the vector of points that lie along the line you fit; if your over-determined linear system is Ax = b, then yLin = projCol Ab. M is the total number of data points.
Print E Linear to your diary.

The quadratic integrate-and-fire equation is a simplified model of how the membrane potential responds to electrical currents:

F(V ) = a(V Vrest)(V Vthr) (4)

where Vrest is a resting voltage and Vthr is the threshold voltage (if I = 0 and V > Vthr, then V will continue to increase very rapidly: which we interpret as a spike). Vthr, Vrest, and a are constants.

The left hand side is known (measured from the experiment): our task is to determine the constants a, Vrest, and Vthr.

(a) Use the normal equations (AT Axˆ = AT b) to fit the data to a parabola: i.e. find C, D and E s.t.

F(V) C+DV+EV2 (5) Print C, D and E to your diary.

(b) Solve for a, Vthr, and Vrest in terms of C, D, and E. That is, find coefficients to equate the two polynomials:

C +DV +EV2 = a(V Vrest)(V Vthr) Print a, Vthr and Vrest to your diary.

(c) Your fitted curve, a(V Vrest)(V Vthr), will not exactly go through all of the data points. Report the average error as follows:

Here yQuad is the vector of points that lie along the parabola you fit, and M is the total number of data points.
Print E Quad to your diary.

5. Maybe we could do better with a different polynomial approximation. Use least-squares to fit the data to a cubic function:

F(V) C+DV+EV2+GV3 (6) Print C, D, E and G to your diary. Report the average error, as above, named

E Cubic. Did you get any improvement?
6. Suggested: You may want to look at the data using the plot command:

Does it look like this should be well-modeled by a quadratic function?

You can also plot your best-fit curves to see how they compare; follow the previous command with

>> hold on;

and/or

>> hold on;

Explanation / Answer

Solution:

% load the datafile
fl=load lab7_data.mat

%whos command
vrbl=whos(fl)

%size command
%prints dimensions of V and Fv to your diary
[Vsz,Fvsz]=size(vrbl)
size(V)
size(Fv)

vrbl(1) = [10:20]’/10; Vsz = 11; Fvsz = 8;
V = (vrbl(1)*ones(1,Fvsz)).^(ones(Vsz,1)*[0:Fvsz-1]);
disp([cond(V) cond(V’*V)])
%function
P = @(vrbl(1))sum(vrbl(1).^[0:Fvsz-1]);
for i = 1:Vsz, y(i) = P(vrbl(1)(i)); end
c = (V’*V)(V’*y’);
disp(c’)
disp(norm(V*c-y’)/sqrt(Vsz));

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote