Can anyone suggest how can I draw a tangent from a given point in line and get its intercept value on y axis?I

4 次查看(过去 30 天)
I have a langmuir probe data and I wish to calculate the Ion saturation current for which I have to plot a tangent to the curve that lies below 0 in the plot from any point on the curve and get its y intercept!
clc;
clear all;
close all;
a = csvread('scope_5.csv',300,1);%Reads the data from the given file and puts it in the defined variable%
Voltage = a(:,1);%Voltage variable is defined from a matrix by selecting all rows of first column%
Vprobe = a(:,2);%Vprobe is defined by selecting rows from second column%
Iprobe = Vprobe./5500;%Probe current is obtained by dividing the Probe voltage by the probe resistance R=5500ohm%
figure(1)
plot(Voltage,Iprobe,'.k','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',16, 'fontweight', 'b')
xlabel('Probe bias Voltage(V)');
ylabel('Probe current(A)');
title('I-V charecterstic curve');
index = find(a(:,2) < 0, 1, 'first');%Finds the cell number where the current changes the sign to give the floating potential value%
Vfloat = Voltage(index);%Finds the Voltage value corresponding to the index to give the floating potential%
display(Vfloat);
hold on
aa = ginput(2);%Takes input from user to define the Ion saturation current from the plot%
zoom on
p = polyfit(aa(:,1),aa(:,2),1);%Fits the four selected point linearly in form of a line%
Isaturation = polyval(p,aa(:,1));
display(Isaturation);%Shows the fitted current saturation data%
Isat=((Isaturation(1,1)+Isaturation(2,1)/2));%Calculates the average of 2 fitted data points and gives the ion saturation current%
plot(aa(:,1),Isaturation,'m','LineWidth',2,'MarkerSize',12);%Plots the linearly fitted line from four points%
hold on
Ie=Iprobe-Isat;
figure(2)
plot(Voltage,Ie,'r','LineWidth',2,'MarkerSize',12);%Plots the Electron current Vs probe bias voltage curve%
set (gca,'fontsize',16, 'fontweight', 'b');
xlabel('Probe bias Voltage(V)');
ylabel('Electron current(A)');
title('Electron current');
grid on
figure(3)
plot(Voltage,log(Ie),'g','LineWidth',2,'MarkerSize',12);%Plots the logarithmic curve of electron current and Bias voltage%
set (gca,'fontsize',16, 'fontweight', 'b');
xlabel('Voltage');
ylabel('Log(Electron current');
grid on
zoom on
bb = ginput(2);
x=polyfit(bb(:,1),bb(:,2),1);%Fits a line for the 2 given input points%
lnIe=polyval(x,bb(:,1));
T=((bb(4)- bb(3))/(bb(2)-(bb(1))));%Finds the Electron temperature from the slope of the fitted line between the 2 selected points%
Te=1/T;
display(Isat);
display(Te);
dI=diff(Ie);
dV=diff(Voltage);
L=dI./dV;
plot(Voltage(1:9701),L,'r','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',16, 'fontweight', 'b');
xlabel('Voltage','fontsize',16, 'fontweight', 'b');
ylabel('dI/dV','fontsize',16, 'fontweight', 'b');
%Calulating the number density%
d=0.001;%Probe diameter in meter%
A=0.785*d^2;%Probe diameter in m2%
k=1.38*10^-23;%Boltzmann constant%
e=1.6*10^-19;%electron charge%
vb=sqrt((1.38*10^-23*T*11604)/(40*1.67*10^-27));%Bohm Velocity in m/s%
nd=((-Isat)/(0.6*e*A*vb));%Number density per m3%
%Calcuating Debye length%
eps =8.85*10^-12;%Permittivity of free space%
DebyeLength=sqrt((eps*k*T)/(nd*e^2));%Debye length in meters%
%Displays all the calculated parameters%
display(vb);%Bohmvelocity%
display (nd);%Displays number density per m3%
display (DebyeLength);%Displays debye length in meters%

采纳的回答

Star Strider
Star Strider 2019-5-17
We do not have your data, however this illustrates the approach:
x = linspace(-5, 5); % Create Data
y = 1-(x./sqrt(1+x.^2)); % Create Data
xi = 1; % Choose x-Coordinate
yi = interp1(x, y, xi); % Use Interplation To Calculate y-Coordinate
h = x(2)-x(1); % Use With ‘gradient’
dydx = gradient(y,h); % Numerical Derivative
dyi = interp1(x, dydx, xi); % Use Interplation To Calculate Slope At ‘xi’
yi_int = (yi - dyi*xi); % Y-Intercept Of Line
y_tngt = dyi*x + yi_int; % Calculate Tangent Line (Optional)
figure
plot(x, y)
hold on
plot(xi, yi, 'sg', 'MarkerSize',10)
plot(x, y_tngt, '-r')
hold off
grid
text(0, yi_int, sprintf('Y-intercept = %.3f \\rightarrow', yi_int), 'HorizontalAlignment','right')
Can anyone suggest how can I draw a tangent from a given point in line and get its intercept value on y axis - 2019 05 17.png

更多回答(3 个)

darova
darova 2019-5-17
Just use simple equation of a line
img.png
Accept the answer please

BHARAT SINGH RAWAT
BHARAT SINGH RAWAT 2019-5-17
Attached is the data file

inturi srivani
inturi srivani 2019-5-30
Can you please tell me why you used 11604 in bohm velocity

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by