Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting discrete sin wave through Latex

Tags:

latex

I am trying to plot a sin wave : 3sin(100*pi*t) through latex where t will be in millisecond. I want to draw the discrete signal which was sampled at Fs = 300 samples/sec.

I have tried this code:

\begin{figure}%Sampled sine squence
 \caption{Discrete Time Signal}
    \begin{tikzpicture}

        \begin{axis}[%
            standard,
            domain = 0:15,
            samples = 13,
            xlabel={$n$},
            ylabel={$x[n]$}]

            \addplot+[ycomb,black,thick] {3*sin(100*180*x/13)};

        \end{axis}
    \end{tikzpicture}
\end{figure} 

\end{document}`

but I am getting a different result than the one I am expecting.

enter image description here

My result should be like plot-B here but I am getting plot-A. Any suggestion, how i should do that?

like image 732
Sakil Chowdhury Avatar asked Jun 30 '26 10:06

Sakil Chowdhury


1 Answers

The code calls for a ycomb of 13 samples across the domain, which is exactly what you get with plot-A (exclusive of endpoints). I believe that you need

samples = 5,

to achieve the desired result.

like image 144
Mike Satteson Avatar answered Jul 07 '26 16:07

Mike Satteson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!