How do I plot this periodic step function with GNUplot?

In summary, the conversation discusses an equation involving a step function and its graph, as well as the challenges of plotting it in different software programs. The use of the modulo operation is also mentioned. The solution involves using iteration in a modern programming language and plotting the numerical results in GNUplot.
  • #1
randombill
81
0
[tex]\sum_{k=0}^{∞} (t-2k) [u(t-2k)-u(t-2(k+1))] = f(t)[/tex]

where [tex]u[/tex] is the step function and the graph of this is supposed to be 45 degree lines repeating to infinity. Sort of like

/ / / / / / / / / ad infinitum. I took this equation out of this lecture note on page 10. Fig 5.4 is supposedly the graph of it and example 5.27 is where they ask to solve it.
 
Last edited:
Physics news on Phys.org
  • #2
What do you know about the modulo operation?
 
  • #3
A lot actually. Thats the % operator in C/C++ right? Actually I figured out that plotting this function is next to impossible in GNUplot based on my searches online and this was actually plotted with Maple. There is a free Maple (clone) called Sage and runs in Oracle VirtualBox but I haven't tried it. What I did figure out is that it would be easier to use iteration (for loop, while, etc) in a modern programming language such as C and substitute that for the summation part of the problem. From there the problem falls together by simply plotting the numerical result from a dat file in GNUplot. I think that solves it.
 
  • #4
I don't think it is difficult to plot this function in gnuplot once you use the modulo operation (which is also in gnuplot represented by the % sign) as it is nothing else than f(t)=t%2
 
  • #5
Okay but what about the periodic part using the summation. That usually requires two independent variables but most 2d graphers can only do one. For the summation you would need k and t to be both variables dynamically changing. I can easily graph one line using 2t but I would still need to repeat it iteratively using summation over k. And shouldn't it be f(t)=k%2?
 

1. How do I input a periodic step function into GNUplot?

To input a periodic step function into GNUplot, you will need to use the "set table" command to create a data file with the values of your function at different points. Then, you can use the "plot" command to graph the data file as a line or points.

2. Can I specify the period and amplitude of the step function in GNUplot?

Yes, you can specify the period and amplitude of the step function by using the "set xrange" and "set yrange" commands, respectively. These commands allow you to set the range of values that will be displayed on the x and y axes of your graph.

3. How do I change the appearance of the step function plot in GNUplot?

To change the appearance of the step function plot, you can use the "set style" command to specify the color, line style, and point style of the plot. You can also add a title, axis labels, and a legend to your plot using the "set title", "set xlabel", "set ylabel", and "set key" commands.

4. Can I plot multiple step functions on the same graph in GNUplot?

Yes, you can plot multiple step functions on the same graph by using the "plot" command with multiple data files or by using the "multiplot" command to create subplots within the same graph.

5. How can I save my step function plot as an image or export it to a file in GNUplot?

To save your step function plot as an image, you can use the "set term" command to specify the output format (e.g. png, jpeg) and then use the "set output" command to specify the file name. You can also use the "save" command to export the data from your plot to a text file.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
34K
  • Programming and Computer Science
Replies
2
Views
4K
  • Calculus and Beyond Homework Help
Replies
20
Views
3K
Replies
11
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Quantum Physics
Replies
31
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
12K
  • Calculus and Beyond Homework Help
Replies
3
Views
2K
Back
Top