How do I extract values from fitting my custom equation to a data set with multiple data entries?
Show older comments
This is for a lab I have to do for class and am sort of stuck at this point. I have a graph with multiple plots. This is at %Plotting Long Channel. I want to fit the equation below to each one of those data sets to extrapolate the mobility term (u) and Threshold Voltage (Vt) for each Vg value. Vt and u are the fitting parameters. At each Vg value I have data sets of Id vs Vd as you can see in my excel spreedsheet. My values for Vg are 0:0.2:1.2. I have the custom fitting toolbox but I am getting no where with it, errors left and right. I want to fit the equation to each of my data sets and find the mobility term that will fit it to the data. Please ignore the Vt already there. I'm trying to get the Vt two seperate ways then compare.

% PLOTTING Id vs Vd
clear all;
clc;
%Long Channel
Vd = xlsread('W1umL3um.xlsx', 'C4:C53');
Id0 = xlsread('W1umL3um.xlsx', 'D56:D5105');
Id2 = xlsread('W1umL3um.xlsx', 'F56:F105');
Id4 = xlsread('W1umL3um.xlsx', 'H56:H105');
Id6 = xlsread('W1umL3um.xlsx', 'J56:J105');
Id8 = xlsread('W1umL3um.xlsx', 'L56:L105');
Id10 = xlsread('W1umL3um.xlsx', 'N56:N105');
Id12 = xlsread('W1umL3um.xlsx', 'P56:P105');
%Short Channel
SVd = xlsread('W1umL60nm.xlsx', 'C4:C53');
SId0 = xlsread('W1umL60nm.xlsx', 'D56:D105');
SId2 = xlsread('W1umL60nm.xlsx', 'F56:F105');
SId4 = xlsread('W1umL60nm.xlsx', 'H56:H105');
SId6 = xlsread('W1umL60nm.xlsx', 'J56:J105');
SId8 = xlsread('W1umL60nm.xlsx', 'L56:L105');
SId10 = xlsread('W1umL60nm.xlsx', 'N56:N105');
SId12 = xlsread('W1umL60nm.xlsx', 'P56:P5105');
%Plotting Long Channel
figure('Name', 'Long Channel IdVd curve');
Lp = plot(Vd, Id0, Vd, Id2, Vd, Id4, Vd, Id6, Vd, Id8, Vd, Id10, Vd, Id12);
title('Drain Voltage vs Drain Current at varying Gate Voltages');
xlabel('Drain Voltage (V)');
ylabel('Drain Current (mA/um)');
legend({'Vg = 0V','Vg = 0.2V','Vg = 0.4V','Vg = 0.6V','Vg = 0.8V','Vg = 1.0V','Vg = 1.2V'},'Location','east')
grid on
%Plotting Short Channel
figure('Name', 'Short Channel IdVd curve');
Sp = plot(SVd, SId0, SVd, SId2, SVd, SId4, SVd, SId6, SVd, SId8, SVd, SId10, SVd, SId12);
title('Drain Voltage vs Drain Current at varying Gate Voltages');
xlabel('Drain Voltage (V)');
ylabel('Drain Current (mA/um)');
legend({'Vg = 0V','Vg = 0.2V','Vg = 0.4V','Vg = 0.6V','Vg = 0.8V','Vg = 1.0V','Vg = 1.2V'},'Location','east');
grid on
%Plotting Id vs Vg for Long Channel @ Vd = 0.2040816
Vg = xlsread('W1umL3um.xlsx','For Vt','D5:D11');
VtId = xlsread('W1umL3um.xlsx','For Vt','E5:E11');
dydx = gradient(VtId,mean(diff(Vg))); % Calculate Numerical Derivative At Every Point
[maxslope,idx] = max(dydx); % Find Maximum Slope & Index
x = Vg(idx);
y = VtId(idx);
intcpt = (y - maxslope*x); % Calculate Tangent Line Intercept
tangentline = maxslope*Vg+intcpt; % Calculate Tangent Line
Vt = ((-2E-6)-intcpt)/maxslope % Minumum X-Axis Intercept
figure('Name','Graph to get Vt');
IdVg = plot(Vg, VtId);
hold on
plot(Vg, tangentline, '--');
hold off
xlabel('Gate Voltage (V)');
ylabel('Drain Current (mA/um)');
legend({'Vd = 0.2040816V', 'Tangent'},'Location','northwest')
ylim([0 max(ylim)])
%Vg for the purpose of finding u
%Mobility equation from long channel equation
10 Comments
Star Strider
on 30 Nov 2018
What are Z,
, and L?
There are insufficient data to estimate them, and because they are products of each other, impossible to estimate them uniquely in any event.
Image Analyst
on 30 Nov 2018
In other words, we can get the estimated parameter alpha, where alpha is the product (mu*Z*Ci/L) but unless we know Z, Ci, and L we can't get mu by itself.
Image Analyst
on 30 Nov 2018
Edited: Image Analyst
on 30 Nov 2018
Code doesn't run. Please also attach 'W1umL60nm.xlsx'.
Ausamah Hobbi
on 30 Nov 2018
Edited: Ausamah Hobbi
on 30 Nov 2018
Star Strider
on 30 Nov 2018
I am testing this first with ‘Id0’.
I get a (50x1) column vector for ‘Vd’.
There is nothing in the matrices for either ‘Id0’ or ‘Id2’.
What specific values of ‘Vg’ apply to these data (when I am able to load them)? It is a (1x7) vector.
Image Analyst
on 30 Nov 2018
Thanks for the workbook. We're getting closer to being able to help you but we're not there yet. No, alpha can't be that constant value. I just made up the name alpha and it included the unknown mu, which we're supposed to estimate, so alpha = mu*Z*ci/L CANNOT be a constant. Again, unless we know Z, Ci, and L we can't get mu by itself.
Ausamah Hobbi
on 30 Nov 2018
Ausamah Hobbi
on 1 Dec 2018
Star Strider
on 1 Dec 2018
I am still not getting anything for ‘Id0’. It is an empty matrix. (I am using the file I downloaded previously, since it has the same name.)
I cannot make any sense out of ‘SVd’ and ‘SId0’. They look completely random.
Ausamah Hobbi
on 2 Dec 2018
Accepted Answer
More Answers (1)
Star Strider
on 1 Dec 2018
I am using this code to estimate your parameters:
Vd = xlsread('W1umL3um.xlsx', 'C4:C53');
Id0 = xlsread('W1umL3um.xlsx', 'D56:D5105');
SVd = xlsread('W1umL60nm.xlsx', 'C4:C53');
SId0 = xlsread('W1umL60nm.xlsx', 'D56:D105');
Vg = 0:0.2:1.2;
% % % b(1) = mu, b(2) = Vt
% Idfcn = @(b,Vd) b(1).*Z*Ci.*(Vg-b(2)).*Vd - Vd.^2/2)./L;
ZCiL = 0.00575;
Idfcn = @(b,Vd) b(1).*ZCiL.*(Vg(1)-b(2)).*Vd - Vd.^2/2;
% [B,fv] = fminsearch(@(b) norm(Id0 - Idfcn(b,Vd)), [1;1]);
[B,fv] = fminsearch(@(b) norm(SId0 - Idfcn(b,SVd)), 1000*rand(2,1));
figure
plot(SVd, SId0, 'p')
hold on
plot(SVd, Idfcn(B,SVd), '-g')
hold off
grid
However, since I cannot use your data (it is either nonexistend or apparently random), I can go not further.
11 Comments
Ausamah Hobbi
on 1 Dec 2018
Ausamah Hobbi
on 2 Dec 2018
Star Strider
on 2 Dec 2018
That is what I referred to as ‘random’. There is no way to fit your model to those data.
Something is obviously wrong (I believe with the data), so until you sort that, I can go no further.
Ausamah Hobbi
on 2 Dec 2018
Ausamah Hobbi
on 3 Dec 2018
Star Strider
on 3 Dec 2018
Congratulations! Thank you!
I do not have the Curve Fitting Toolbox, so I cannot run your code.
You appear to have several different plots with different legend entries and figure names, so I am not certain what you want to do with all of them. The easiest way may be to combine them as different axes in the same figure, using the subplot (link) function.
If you want them all in the same figure, do something like this:
figure
h1 = plot( fitresult_1, xData, yData, 'DisplayName', 'Vg = 0V');
hold on
h2 = plot( fitresult_2, xData, yData, 'DisplayName', 'Vg = 10.2V');
h3 = plot( fitresult_3, xData, yData, 'DisplayName', 'Vg = 0.4V');
h4 = plot( fitresult_4, xData, yData, 'DisplayName','Vg = 0.6V');
h5 = plot( fitresult_5, xData, yData, 'DisplayName','Vg = 0.8V');
h6 = plot( fitresult_6, xData, yData, 'DisplayName','Vg = 1.0V');
h7 = plot( fitresult_7, xData, yData, 'DisplayName','Vg = 1.2V');
hold off
hl = legend;
hl.Location = 'NE';
grid
That should work. However, since I cannot run your code, I am specifying that my code here is UNTESTED.
Note that this requires that you label each ‘fitresult’ and probably ‘gof’ uniquely. (You might be able to store these as numeric or cell array elements instead. I do not know the variable class the are, so I cannot specify that.)
I will consider running your code with fitting procedures that I have available (Statistics and Machine Learning Toolbox, Optimization Toolbox) to see what the result is, simply out of curiosity.
Ausamah Hobbi
on 3 Dec 2018
Ausamah Hobbi
on 3 Dec 2018
Star Strider
on 3 Dec 2018
No hassle, so no worries.
The cftool App is part of the Curve Fitting Toolbox. I do not have it, and cannot download and install it.
With respect to Using the curve fitting tool to find fitting parameters of an integral (the one you linked to), you will need to examine those functions and either use the Symbolic Math Toolbox, or re-write them to accuunt for the multiple arguments in them.
For example:
p = @(Vg,Vt) CoRo*(Vg-Vt);
...
b = @(SVd,Vg,Vt) sqrt(a^2+4*exp(SVd)*(exp(p(Vg,Vt))-1));
and so for all the others.
You will also have to create appropriate symbolic functions if you choose to use the Symbolic Math Toolbox and the matlabFunction function to create your anonymous function to use with integral.
Ausamah Hobbi
on 3 Dec 2018
Edited: Ausamah Hobbi
on 3 Dec 2018
Ausamah Hobbi
on 4 Dec 2018
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!