1

I am trying to find the intersection 2 plots in pgfplots and extract the x-values onto a pgfplotstable?

Here is a code where Symm and Load plots intersect and I could to get the x-value of intersection, but when I try to store the value using \pgfplotstableread, I am getting error. Also, error pops when I try to append the row value to table1.

enter image description here

%% Preamble    
%For getting gnuplot coordinates
\newlength{\len}
\newlength{\plotwidth}
\newlength{\het}
\newlength{\plotheight}

\newcommand{\getvalue}[1]{\pgfkeysvalueof{/pgfplots/#1}}
\begin{document}
\begin{figure}
\pgfplotsset{
 compat=1.11,
 /pgf/declare function={
% drain current above pinch off
Ida(\Kn,\lamda,\WL,\Vg,\Vt,\Vd)=0.5*\Kn*\WL*(\Vg-\Vt)^2;
Idb(\Kn,\lamda,\WL,\Vg,\Vt,\Vd)=0.5*\Kn*\WL*(\Vg-\Vt)^2*(1+(\lamda*\Vd));
% drain current below pinch off
Idc(\Kn,\lamda,\WL,\Vg,\Vt,\Vd)=0.5*\Kn*\WL*(2*(\Vg-\Vt)-\Vd)*\Vd;
},
}
\begin{tikzpicture}[transform shape, scale=0.75]
%%
\begin{axis}[
width=\textwidth,
%height=\textwidth,
xmin=-0.1, xmax=15.5,
ymin=-0.1,ymax=5,
axis line style={<->},
samples=101,
axis x line=middle,
axis y line=middle,
ticks=none,
]
\def\Vdd{3}
\def\Kn{50*10^(-3)}
\def\WL{10}
\def\lamda{0.001}
\def\Vt{0.7}
\def\Rd{1}

\pgfplotstableread[row sep=\\,col sep=comma, columns={x,y}]{
x,y \\
1, 13 \\
}\table1%

\addplot[draw=none,name path global={load}, blue, samples=10, domain=0:15]{5-(\x/3)};

\pgfplotsinvokeforeach{2,...,10}{
\addplot[name path global={Symm}, smooth, cyan, samples=101, domain=0:15] {
    (\x<#1*0.5-\Vt) ? Idc(\Kn,\lamda,\WL,#1*0.5,\Vt,\x) : Idb(\Kn,\lamda,\WL,#1*0.5,\Vt,\x)
     };
     \path[name intersections={of={Symm} and {load}, by={point#1}, name=j}](j-1)
\pgfextra{
    \pgfextractx{\len}{\pgfpointdiff{\pgfplotspointaxisxy{0}{0}}{\pgfpointanchor{j-1}{center}}}
    \pgfextractx{\plotwidth}{\pgfpointdiff{\pgfplotspointaxisxy{\getvalue{xmin}}{0}}%
    {\pgfplotspointaxisxy{\getvalue{xmax}}{0}}}%
    \pgfmathparse{\len/\plotwidth*15}%since xmax=15
    \global\let\macrox\pgfmathresult%
    \xdef\intsectX{\getvalue{xmax}}%
}   
    (j-1)node[circ]{}node[left]{\macrox};

\pgfplotstableread[row sep=\\,col sep=comma, columns={x,y},
columns/y/.style={numeric type}
]{
x,y \\
1, \macrox \\   <- *Error 1: ! Package PGF Math Error: Could not parse input '' as a floating point number, sorry. The unreadable part was near ''..*
}\sum%

    % Concatenate


%%% <- Error 2: ! Undefined control sequence. \sum ->\pgfpl@@{x}\pgfpl@@ {y }l.378 };
 %  \pgfplotstablevertcat{\table1}{\sum} 

    };  
\pgfplotstabletypeset\sum%  

\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
3
  • pgfplotstable only reads data off files, OTOH, you can create a comma delimited string of values using \xdef. A similar approach was used in tex.stackexchange.com/questions/449138/… for extra x ticks. Commented Jun 21, 2019 at 13:55
  • If you want others to seriously look at your problem, provide a minimal example that, apart from the reported issue, is compilable. It should start with \documentclass and end with \end{document} and should have all commands like \getvalue defined.
    – user121799
    Commented Jun 21, 2019 at 19:53
  • I have added the preambles. Help me in getting out the values of intersects on a table.
    – Raja
    Commented Jun 22, 2019 at 2:31

0

You must log in to answer this question.

Browse other questions tagged .