I am trying to plot a best-fit trendline to an I-V curve for a Zener diode. The data is exponential so linear regression is not suitable in this instance.
Here is my data. The important columns are 2 and 3, which are current and voltage, respectively. In this case, the current data is being plotted as a function of voltage.
column 1,column 2,column 3
-15.0,-13.33,-0.71
-11.2,-9.71,-0.696
-7.50,-6.30,-0.675
-3.76,-3.45,-0.636
0,0,0
3.76,3.00,0.639
7.51,6.56,0.676
11.2,10.16,0.696
15,13.7,0.71
Here is part of the code I am working with:
\documentclass{article}
\usepackage{tikz, pgfplots, pgfplotstable, siunitx}
\usepgfplotslibrary{units}
\sisetup{
round-mode = places,
round-precision = 2,
}
\begin{document}
\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
width=\linewidth,
grid=major,
grid style={dashed,gray!30},
xlabel=Voltage,
ylabel=Current,
x unit=\si{\volt},
y unit=\si{\milli\ampere},
legend style={at={(0.5,1.4)},anchor=north},
x tick label style={rotate=90,anchor=east}
]
\addplot [only marks, mark = *, blue] table[x=column 3,y=column 2,col sep=comma]{tables/Table 6.csv};
\addlegendentry{$y(x)$}
\end{axis}
\end{tikzpicture}
\caption{Zener diode reverse bias}
\end{center}
\end{figure}
\end{document}
smoothingspline
fitting in MATLAB) will do.