# GNU Octave - question about graphs and plotting

I've had task to do - to make an graphical interpretation of adding two functions together: sin(8x) and multiplied -sign(x) in Octave, as shown on image above. And I've done that, but I don't know how to get rid of these lines, which link up gaps between separated values (for example, -1 and 1). I don't want them to be seen especially in third graph.

To make helping me easier, I'm going to tell you what I did:

1. I made linear series of numbers, from -100 to 99 (tempx).
2. tempy = -sign(tempx)
3. y1 = [tempy tempy tempy tempy] (this line is kinda funny, if you know Polish language)
4. Creating y2 - sinus function
5. y3 = y2 + y1
6. Plotting, subplotting...
7. Screenshot

Awaiting for instructions...

-

in default mode plot connects all the points with a line. with plot(y3,'.') you just plot the actual points itself. you can choose between different symbols to plot like '*', 'x' and more.

http://www.gnu.org/software/octave/doc/interpreter/Two_002dDimensional-Plots.html#Two_002dDimensional-Plots

If you really need to connect the points, you can split the vector in different subvectors and plot them all separate.

``````t = [0:1:9];
x = [ones(1,5) -ones(1,5)];

figure(1)
plot(t(1:5),x(1:5),'b',t(6:end),x(6:end),'b')
axis([0 10, -2 2])
``````
-
I've used solution with '.', but there were a single points with value of 0. So I've looked into my data series and then I've changed these points to -1. And it looks alright now. Your second tip seemed to me hard to adapt to my task. Anyway thanks for help and inspiration :) – Twórca Oct 26 '13 at 17:46