Plotting a rectangular waveform with LaTeX
up vote
4
down vote
favorite
I need to plot a rectangular waveform with Latex. The main problem is how to make the height of the pulse "variable" not a "number" as you can see in the figure below. "x" here is some variable that will be found by calculations.
tikz-pgf diagrams pstricks pst-plot
add a comment |
up vote
4
down vote
favorite
I need to plot a rectangular waveform with Latex. The main problem is how to make the height of the pulse "variable" not a "number" as you can see in the figure below. "x" here is some variable that will be found by calculations.
tikz-pgf diagrams pstricks pst-plot
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I need to plot a rectangular waveform with Latex. The main problem is how to make the height of the pulse "variable" not a "number" as you can see in the figure below. "x" here is some variable that will be found by calculations.
tikz-pgf diagrams pstricks pst-plot
I need to plot a rectangular waveform with Latex. The main problem is how to make the height of the pulse "variable" not a "number" as you can see in the figure below. "x" here is some variable that will be found by calculations.
tikz-pgf diagrams pstricks pst-plot
tikz-pgf diagrams pstricks pst-plot
edited Nov 23 at 17:44
Artificial Stupidity
4,57511034
4,57511034
asked Nov 23 at 14:10
Ali A.
232
232
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
A PSTricks solution just for comparison purpose.
documentclass[pstricks,border=12pt,12pt]{standalone}
usepackage{pst-plot}
begin{document}
begin{pspicture}(-1,-1)(11.5,5.5)
psaxes[ticks=x,labels=x]{->}(0,0)(-1,-1)(11,5)[$t$,0][$A(t)$,90]
multips(0,0)(2,0){5}{psline[linecolor=blue,linewidth=2pt](0,0)(0,4)(1,4)(1,0)(2,0)}
uput{5pt}[180](0,4){$sqrt{R_s}$}
end{pspicture}
end{document}
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
|
show 1 more comment
up vote
2
down vote
Since this question is tagged tikz-pgf
, I thought you may also be interested in a TikZ code. (One of its advantageous is that this works with pretty much any compiler.)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
pgfmathsetmacro{h}{2}
pgfmathsetmacro{L}{4}
draw[thick,-latex] (0,-0.5) -- (0,h+2) node[above] {$A(t)$};
draw[thick,-latex] (-0.5,0) -- (2*L+1,0) node[right] {$t$};
foreach X [evaluate=X as Z using {int(2*X-1)},] in {1,...,L}
{draw[very thick,blue] (2*X-2,0) |- (2*X-1,h) |- (2*X,0);
draw (Z,0.1) -- (Z,-0.1) node[below]{$Z$};}
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
A simple approach using TikZ.
documentclass[border=3.14mm]{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
defx{1} % replace 1 with desired value here
draw[-latex] (0,0) -- ++(4,0) node[right]{$t$};
draw[-latex] (0,0) -- ++(0,2.0x)node[left]{$A(t)$};
draw[thick] (0,x)node[left]{$sqrt{x}$} -- ++(1,0) -- ++(0,-x)node[below]{1} -- ++(1,0) -- ++(0,x) -- ++(1,0) -- ++(0,-x)node[below]{3} -- ++(0.5,0);
end{tikzpicture}
end{document}
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
A PSTricks solution just for comparison purpose.
documentclass[pstricks,border=12pt,12pt]{standalone}
usepackage{pst-plot}
begin{document}
begin{pspicture}(-1,-1)(11.5,5.5)
psaxes[ticks=x,labels=x]{->}(0,0)(-1,-1)(11,5)[$t$,0][$A(t)$,90]
multips(0,0)(2,0){5}{psline[linecolor=blue,linewidth=2pt](0,0)(0,4)(1,4)(1,0)(2,0)}
uput{5pt}[180](0,4){$sqrt{R_s}$}
end{pspicture}
end{document}
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
|
show 1 more comment
up vote
4
down vote
accepted
A PSTricks solution just for comparison purpose.
documentclass[pstricks,border=12pt,12pt]{standalone}
usepackage{pst-plot}
begin{document}
begin{pspicture}(-1,-1)(11.5,5.5)
psaxes[ticks=x,labels=x]{->}(0,0)(-1,-1)(11,5)[$t$,0][$A(t)$,90]
multips(0,0)(2,0){5}{psline[linecolor=blue,linewidth=2pt](0,0)(0,4)(1,4)(1,0)(2,0)}
uput{5pt}[180](0,4){$sqrt{R_s}$}
end{pspicture}
end{document}
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
|
show 1 more comment
up vote
4
down vote
accepted
up vote
4
down vote
accepted
A PSTricks solution just for comparison purpose.
documentclass[pstricks,border=12pt,12pt]{standalone}
usepackage{pst-plot}
begin{document}
begin{pspicture}(-1,-1)(11.5,5.5)
psaxes[ticks=x,labels=x]{->}(0,0)(-1,-1)(11,5)[$t$,0][$A(t)$,90]
multips(0,0)(2,0){5}{psline[linecolor=blue,linewidth=2pt](0,0)(0,4)(1,4)(1,0)(2,0)}
uput{5pt}[180](0,4){$sqrt{R_s}$}
end{pspicture}
end{document}
A PSTricks solution just for comparison purpose.
documentclass[pstricks,border=12pt,12pt]{standalone}
usepackage{pst-plot}
begin{document}
begin{pspicture}(-1,-1)(11.5,5.5)
psaxes[ticks=x,labels=x]{->}(0,0)(-1,-1)(11,5)[$t$,0][$A(t)$,90]
multips(0,0)(2,0){5}{psline[linecolor=blue,linewidth=2pt](0,0)(0,4)(1,4)(1,0)(2,0)}
uput{5pt}[180](0,4){$sqrt{R_s}$}
end{pspicture}
end{document}
edited Nov 23 at 15:12
answered Nov 23 at 14:24
Artificial Stupidity
4,57511034
4,57511034
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
|
show 1 more comment
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Thank you so much for your help. However, when I tried to run the codes you gave me, it gives me the following error: ! Undefined control sequence. c@lor@to@ps ->PSTricks _Not_Configured_For_This_Format l.6 ...xes{->}(0,0)(-1,-1)(12,5)[$t$,0][$A(t)$,90] ?
– Ali A.
Nov 23 at 14:31
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Can you please help me more? How I can use these options? Thanks.
– Ali A.
Nov 23 at 14:37
Yes I use win 10
– Ali A.
Nov 23 at 14:39
Yes I use win 10
– Ali A.
Nov 23 at 14:39
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
This works.. :) One more thing please, How can I can make the height of the pulses in terms of a variable not number, as I mentioned in my post and as shown in the figure I attached to it. Many thanks..
– Ali A.
Nov 23 at 14:47
1
1
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
Thank you so much for your time and help. It works perfectly now.. :)
– Ali A.
Nov 23 at 15:15
|
show 1 more comment
up vote
2
down vote
Since this question is tagged tikz-pgf
, I thought you may also be interested in a TikZ code. (One of its advantageous is that this works with pretty much any compiler.)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
pgfmathsetmacro{h}{2}
pgfmathsetmacro{L}{4}
draw[thick,-latex] (0,-0.5) -- (0,h+2) node[above] {$A(t)$};
draw[thick,-latex] (-0.5,0) -- (2*L+1,0) node[right] {$t$};
foreach X [evaluate=X as Z using {int(2*X-1)},] in {1,...,L}
{draw[very thick,blue] (2*X-2,0) |- (2*X-1,h) |- (2*X,0);
draw (Z,0.1) -- (Z,-0.1) node[below]{$Z$};}
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
Since this question is tagged tikz-pgf
, I thought you may also be interested in a TikZ code. (One of its advantageous is that this works with pretty much any compiler.)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
pgfmathsetmacro{h}{2}
pgfmathsetmacro{L}{4}
draw[thick,-latex] (0,-0.5) -- (0,h+2) node[above] {$A(t)$};
draw[thick,-latex] (-0.5,0) -- (2*L+1,0) node[right] {$t$};
foreach X [evaluate=X as Z using {int(2*X-1)},] in {1,...,L}
{draw[very thick,blue] (2*X-2,0) |- (2*X-1,h) |- (2*X,0);
draw (Z,0.1) -- (Z,-0.1) node[below]{$Z$};}
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
up vote
2
down vote
Since this question is tagged tikz-pgf
, I thought you may also be interested in a TikZ code. (One of its advantageous is that this works with pretty much any compiler.)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
pgfmathsetmacro{h}{2}
pgfmathsetmacro{L}{4}
draw[thick,-latex] (0,-0.5) -- (0,h+2) node[above] {$A(t)$};
draw[thick,-latex] (-0.5,0) -- (2*L+1,0) node[right] {$t$};
foreach X [evaluate=X as Z using {int(2*X-1)},] in {1,...,L}
{draw[very thick,blue] (2*X-2,0) |- (2*X-1,h) |- (2*X,0);
draw (Z,0.1) -- (Z,-0.1) node[below]{$Z$};}
end{tikzpicture}
end{document}
Since this question is tagged tikz-pgf
, I thought you may also be interested in a TikZ code. (One of its advantageous is that this works with pretty much any compiler.)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
pgfmathsetmacro{h}{2}
pgfmathsetmacro{L}{4}
draw[thick,-latex] (0,-0.5) -- (0,h+2) node[above] {$A(t)$};
draw[thick,-latex] (-0.5,0) -- (2*L+1,0) node[right] {$t$};
foreach X [evaluate=X as Z using {int(2*X-1)},] in {1,...,L}
{draw[very thick,blue] (2*X-2,0) |- (2*X-1,h) |- (2*X,0);
draw (Z,0.1) -- (Z,-0.1) node[below]{$Z$};}
end{tikzpicture}
end{document}
answered Nov 23 at 16:26
marmot
79.5k490168
79.5k490168
add a comment |
add a comment |
up vote
2
down vote
A simple approach using TikZ.
documentclass[border=3.14mm]{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
defx{1} % replace 1 with desired value here
draw[-latex] (0,0) -- ++(4,0) node[right]{$t$};
draw[-latex] (0,0) -- ++(0,2.0x)node[left]{$A(t)$};
draw[thick] (0,x)node[left]{$sqrt{x}$} -- ++(1,0) -- ++(0,-x)node[below]{1} -- ++(1,0) -- ++(0,x) -- ++(1,0) -- ++(0,-x)node[below]{3} -- ++(0.5,0);
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
A simple approach using TikZ.
documentclass[border=3.14mm]{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
defx{1} % replace 1 with desired value here
draw[-latex] (0,0) -- ++(4,0) node[right]{$t$};
draw[-latex] (0,0) -- ++(0,2.0x)node[left]{$A(t)$};
draw[thick] (0,x)node[left]{$sqrt{x}$} -- ++(1,0) -- ++(0,-x)node[below]{1} -- ++(1,0) -- ++(0,x) -- ++(1,0) -- ++(0,-x)node[below]{3} -- ++(0.5,0);
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
up vote
2
down vote
A simple approach using TikZ.
documentclass[border=3.14mm]{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
defx{1} % replace 1 with desired value here
draw[-latex] (0,0) -- ++(4,0) node[right]{$t$};
draw[-latex] (0,0) -- ++(0,2.0x)node[left]{$A(t)$};
draw[thick] (0,x)node[left]{$sqrt{x}$} -- ++(1,0) -- ++(0,-x)node[below]{1} -- ++(1,0) -- ++(0,x) -- ++(1,0) -- ++(0,-x)node[below]{3} -- ++(0.5,0);
end{tikzpicture}
end{document}
A simple approach using TikZ.
documentclass[border=3.14mm]{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
defx{1} % replace 1 with desired value here
draw[-latex] (0,0) -- ++(4,0) node[right]{$t$};
draw[-latex] (0,0) -- ++(0,2.0x)node[left]{$A(t)$};
draw[thick] (0,x)node[left]{$sqrt{x}$} -- ++(1,0) -- ++(0,-x)node[below]{1} -- ++(1,0) -- ++(0,x) -- ++(1,0) -- ++(0,-x)node[below]{3} -- ++(0.5,0);
end{tikzpicture}
end{document}
answered Nov 23 at 16:37
nidhin
1,927922
1,927922
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461415%2fplotting-a-rectangular-waveform-with-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown