Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Get Rid of it

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...

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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])
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.