Using least squares to find the x intercept.

7 Ansichten (letzte 30 Tage)
madhan ravi
madhan ravi am 30 Dez. 2019
Kommentiert: madhan ravi am 30 Dez. 2019
I have a set of data points which represent the IV characteristics of a diode. I'm confused on how to get the threshold voltage (x intercept) of that diode. Any suggestions and ideas are welcomed. Illustration:
34e29d4a-a2d4-4d88-bbb7-13a485abc2a1.JPG
  5 Kommentare
John D'Errico
John D'Errico am 30 Dez. 2019
The point being, you cannot do any prediction (x intercept, for example) without a model of the process. Matt suggests what might be a decent one, but very often there is some model suggested by physical principals. If so, then it makes a great dela of sense to use it.
But what it relly looks like from your drawing is that you do not want the actual curve drawn, but the equation of a tangent line, drawn from some specific point on the curve. Then you might want to find the x intercept of that line.
Or, perhaps the curve drawn is supposed to be asymptotically linear. And you want to find the equation of the asymptote. Given the asymptote equation, it will be easy to find the x intercept. But that asymptote cannot be found without knowing a model for your process.
Still though, without knowing exactly what line is to be created, or how it might be defined, you cannot predict an intercept.
Essentially, we need more than just a drawing.
madhan ravi
madhan ravi am 30 Dez. 2019
Bearbeitet: madhan ravi am 30 Dez. 2019
"But what it relly looks like from your drawing is that you do not want the actual curve drawn, but the equation of a tangent line, drawn from some specific point on the curve. Then you might want to find the x intercept of that line." - that seems to make more sense.Thanks Matt and John D'Errico the model seems to be the one which sir Image Analyst has mentioned below. The point maybe the one at the upper right most point. This intercept which would be found by the experimentation should approximately be near to the literature value of Schottky diode which appears to be in the range from .15 - .45 volts. I really want to make use of MATLAB not interested in using any other softwares than MATLAB. The logic of this method would be helpful for me to apply for all the tasks.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 30 Dez. 2019
Note that if you're using the Shockley_diode_equation,
08086e72556f3cf441163d5403f5b104590acae0
or essentially I = a * exp(b * V) + c, then the intersection of the slope line depends on where the slope is evaluated. This is because the exponential function f( x) = e x has the special property that its derivative is the function itself, f′( x) = e x = f( x). So, do you want the slope at the last x that you have provided in your text file? If so, the slope is pretty easy to compute analytically. It's slope = a * b * exp(b * V). So use fitnlm() to figure out a, b, and c (using attached demo), then plug in a, b, and V to get the slope at that point. Then, knowing the slope and using the point-slope version of the equation for a line passing through that right-most point, you can get the equation of the line, then set that equal to 0 and solve for V.
Let me know if you want a fully worked out solution.
  3 Kommentare
Image Analyst
Image Analyst am 30 Dez. 2019
See this:
% Uses fitnlm() to fit a non-linear model (an exponential decay curve) through noisy data.
% Requires the Statistics and Machine Learning Toolbox, which is where fitnlm() is contained.
% Initialization steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
filename = fullfile(pwd, 'shottky_simr1.txt')
strData = importdata(filename)
X = strData.data(:, 1);
Y = strData.data(:, 2);
% Now we have noisy training data that we can send to fitnlm().
% Plot the noisy initial data.
plot(X, Y, 'b.', 'LineWidth', 2, 'MarkerSize', 15);
grid on;
hold on
beta0 = [0.01, -0.0000001, -0.1]; % Guess values to start with. Just make your best guess.
% y = beta0(1) * exp(beta0(1)*X) + beta0(3);
% plot(X, y, 'r-');
% Convert X and Y into a table, which is the form fitnlm() likes the input data to be in.
tbl = table(X(:), Y(:));
% Define the model as Y = a + exp(-b*x)
% Note how this "x" of modelfun is related to big X and big Y.
% x((:, 1) is actually X and x(:, 2) is actually Y - the first and second columns of the table.
modelfun = @(b,x) b(1) * exp(b(2)*x(:, 1)) + b(3);
% Now the next line is where the actual model computation is done.
mdl = fitnlm(tbl, modelfun, beta0);
% Now the model creation is done and the coefficients have been determined.
% YAY!!!!
% Extract the coefficient values from the the model object.
% The actual coefficients are in the "Estimate" column of the "Coefficients" table that's part of the mode.
coefficients = mdl.Coefficients{:, 'Estimate'}
% Create smoothed/regressed data using the model:
yFitted = coefficients(1) * exp(coefficients(2)*X) + coefficients(3);
% Now we're done and we can plot the smooth model as a red line going through the noisy blue markers.
hold on;
plot(X, yFitted, 'r-', 'LineWidth', 2);
grid on;
title('Exponential Regression with fitnlm()', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
legendHandle = legend('Actual Y', 'Fitted Y', 'Location', 'north');
legendHandle.FontSize = 30;
formulaString = sprintf('Y = %.3e * exp(%.3g * X) + %.3g', coefficients(1), coefficients(2), coefficients(3))
yl = ylim;
text(-0.25, mean(yl), formulaString, 'FontSize', 25, 'FontWeight', 'bold', 'Color', 'r');
% Get slope at xMax
[xMax, indexAtXMax] = max(X)
yMax = Y(indexAtXMax)
slope = coefficients(1) * coefficients(2) * exp(coefficients(2) * xMax)
% Point slope formula (y-yMax) = slope * (x-xMax)
% Get the formula for y=0, and x=xMax
% -yMax/slope = (x - xMax)
x0 = -yMax / slope + xMax
% Plot a * there
plot(x0, 0, 'r*', 'MarkerSize', 20, 'LineWidth', 2);
line([x0, xMax], [0, yMax], 'Color', 'r', 'LineWidth', 2);
caption = sprintf('(%3e, 0)', x0);
text(x0, -0.001, caption, 'FontSize', 25, 'FontWeight', 'bold', 'Color', 'r');
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
You can see the fit is very good, and the tangent at the last point intersects the x axis at
x0 =
0.235560584047374
madhan ravi
madhan ravi am 30 Dez. 2019
Bulleye! An absolute masterpiece. This forum is the best and this feels like home:) Been struggling with this for days and should have asked this long back!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by