3

I want to draw a limited sine curve.

My problem is, that I know how to draw 1/4 sin but not how to get only a section of it.

\setlength{\unitlength}{1mm}
\begin{minipage}{\linewidth}
    \begin {nofloat}{figure}
        \begin{center}
            \begin{tikzpicture}[ cross/.style={draw, cross out,
              minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}, x=1cm, y=1cm]

               \colorlet{grey}{black!50}

               \draw[-,thick,dashed] (-4,2) node[left] {$UpperLimit$} -- (2,2);
               \draw[->,thick] (-4,1)   -- (2,1)node[right] {$t$};
               \draw[-,thick,dashed] (-4,0) node[left] {$LowerLimit$} -- (2,0);
               \draw[->,thick] (-3,-0.5)  -- (-3,2.5)node[above] {$\textcolor{grey}{u} |\textcolor{red}{ \ind{u}{Clipped}}$};

               \draw[thick, dashed, grey] (-3,1) sin (-2,2.5);
               \draw[thick, dashed, grey] (-2,2.5) cos (-1,1);
               \draw[thick, dashed, grey] (-1,1) sin (0,-0.5);
               \draw[thick, dashed, grey] (0,-0.5) cos (1,1);

                \draw[ultra thick, red] (-3,1) sin (-2,2.5);
                \draw[ultra thick, red] (-2.53545,2)   -- (-1.46455,2);
                \draw[ultra thick, red] (-2,2.5) cos (-1,1);
                \draw[ultra thick, red] (-1,1) sin (0,-0.5);
                \draw[ultra thick, red] (-0.53545,0)   -- (0.53545,0);
                \draw[ultra thick, red] (0,-0.5) cos (1,1);

          %     \draw [red,thick,domain=0:-2.53545] plot ( {1.5*sin(\x*2*pi/4)+1}); 
            \end{tikzpicture}
        \end{center}
        \caption{Effect of the Accuracy Shutdown}
        \label{fig:accshut}
    \end{nofloat}
\end{minipage}

I would like something like at the minimum but what I only can produce is something like the maximum.

enter image description here

  • Welcome to TeX.SX. Please include complete minimum working examples, from \documentclass to \end{document} with all significant packages and own commands. – Ignasi Nov 7 '17 at 11:12
5

Define a clipping area before drawing the red line:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\setlength{\unitlength}{1mm}
\begin{minipage}{\linewidth}
 %   \begin{nofloat}{figure}
        \begin{center}
            \begin{tikzpicture}[ cross/.style={draw, cross out,
              minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}, x=1cm, y=1cm]

               \colorlet{grey}{black!50}

               \draw[-,thick,dashed] (-4,2) node[left] {$UpperLimit$} -- (2,2);
               \draw[->,thick] (-4,1)   -- (2,1)node[right] {$t$};
               \draw[-,thick,dashed] (-4,0) node[left] {$LowerLimit$} -- (2,0);
               \draw[->,thick] (-3,-0.5)  -- (-3,2.5)node[above] {$\textcolor{grey}{u} |\textcolor{red}{d}$};

               \draw[thick, dashed, grey] (-3,1) sin (-2,2.5);
               \draw[thick, dashed, grey] (-2,2.5) cos (-1,1);
               \draw[thick, dashed, grey] (-1,1) sin (0,-0.5);
               \draw[thick, dashed, grey] (0,-0.5) cos (1,1);

                    {
                    \clip (-3,0) rectangle (1,2);
                \draw[ultra thick, red] (-3,1) sin (-2,2.5);
                \draw[ultra thick, red] (-2.53545,2) -- (-1.46455,2);
                \draw[ultra thick, red] (-2,2.5) cos (-1,1);
                \draw[ultra thick, red] (-1,1) sin (0,-0.5);
                \draw[ultra thick, red] (-1,1) sin (0,-0.5);
                \draw[ultra thick, red] (-0.53545,0)   -- (0.53545,0);
                \draw[ultra thick, red] (0,-0.5) cos (1,1);}

          %     \draw [red,thick,domain=0:-2.53545] plot ( {1.5*sin(\x*2*pi/4)+1}); 
            \end{tikzpicture}
        \end{center}
%        \caption{Effect of the Accuracy Shutdown}
%        \label{fig:accshut}
%    \end{nofloat}
\end{minipage}
\end{document}

enter image description here

6

an alternative, with use of plot functions and intersections:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,intersections}

\begin{document}
\begin{tikzpicture}[
LR/.style = {draw=red,  ultra thick,   line cap=round},
LG/.style = {draw=gray, thick, dashed, line cap=round},
        > = Straight Barb
                    ]
% limit
\def\LLV{1}   % <--- for setings of  limiter level value                 
% axis
\draw[->,thick] (-1,0.0) -- ++ (5,0.0) node[right] {$t$};
\draw[->,thick] (0,-2.2) -- ++ (0,4.4) node[above] {\textcolor{gray}{$u|$}%
                                                  \textcolor{red}{ $d$}};
% limits
\coordinate (UL) at (-0.5, \LLV); 
\coordinate (LL) at (-0.5,-\LLV); 
\draw[LG, name path=A]
    (UL) node[left] {\textit{UpperLimit}} -- ++ (4,0);
\draw[LG, name path=B]
    (LL) node[left] {\textit{LowerLimit}} -- ++ (4,0)
         coordinate (LD);
% sinusoide
\draw[thick, dashed, gray, name path=S]
    plot[domain=0:6.28, samples=60] (\x/2,{2*sin(\x r)});
\draw[LR,
      name intersections={of=A and S, by={u1,u2}}]
        (u1) -- (u2);
\draw[LR,
      name intersections={of=B and S, by={l1,l2}}]
        (l1) -- (l2);
% cliped sinusoide
\clip (UL) rectangle (LD);
\draw [LR]
    plot[domain=0:6.28, samples=60] (\x/2,{2*sin(\x r)});
\end{tikzpicture}
\end{document}

with setting \LLV you can easy change limiter clamping levels. with this is given additional flexibility of proposed solution.

enter image description here

  • Is it also possible to limit it vertical ? like a Deadzone? Something like: www2.pic-upload.de/img/34499039/clippedAndDeadzoneSine.png – chrisdi91 Dec 19 '17 at 13:58
  • yes, it is possible. but for this is a new question. i suggest you to ask it, that it will be visible to wider audience. – Zarko Dec 19 '17 at 15:04
  • I used the clipped solution below with two clippings ( \clip (-2.8,1) rectangle (-1.2,2.025); and \clip (-0.9,-0.32) rectangle (0.9,1); ) each placed between a \begin{scope} \end{scope} – chrisdi91 Jan 9 '18 at 9:34
  • i@chrisdi91, if this gives you desired result, than it is ok. if this belong to some new question, please write this as answer with your solution of the your new problem. here as comment is not well visible to audience an consequently to other members with similar problem – Zarko Jan 9 '18 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.