Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How do I plot this periodic step function with GNUplot?

  1. May 6, 2013 #1
    [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: May 6, 2013
  2. jcsd
  3. May 10, 2013 #2

    DrDu

    User Avatar
    Science Advisor

    What do you know about the modulo operation?
     
  4. May 11, 2013 #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.
     
  5. May 11, 2013 #4

    DrDu

    User Avatar
    Science Advisor

    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
     
  6. May 11, 2013 #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?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How do I plot this periodic step function with GNUplot?
Loading...