Re: can matlab plot data by condition



Thank you for your answer, but this method seems plot dot by
dot, in my test, it performs slower than mine, but thanks
anyway.

adinda <adinda.vandenberg@xxxxxxxxx> wrote in message
<1193824563.494029.291520@xxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On 31 okt, 07:47, "Ha Wanger"
<virtualcyberinfo+nos...@xxxxxxxxx>
wrote:
I have two matrix like these:
X = [1 2 3 4 5 6]
Y = [-3 -1 -2 2 -1 1]

I want to have a line-dot plot and when Y<0, the dot is red;
when Y>0, the dot is blue.

Now I'm using the follwing method:
1. creat two matrixs foo1 & foo2 from [X;Y]
foo1 = [1 2 3 5 ; -3 -1 -2 -1]
foo2 = [4 6 ; 2 1]
2. plot(foo1(1,:),foo1(2:,),'.r')
plot(foo2(1,:),foo2(2:,),'.b')
plot(X,Y,'-')

actually,the matrixs X & Y are very big so this method is
some inefficient.

Can anyone give me a better method? Thanks!

Probably there are better ways than this, but hey (X and Y
are vectors
right?)

for k=1:length(Y)
if Y(k)>0
plot(X(k),Y(k),'b'), hold on
else plot(X(k),Y(k),'r'), hold on
end
end
hold off


.



Relevant Pages

  • Re: A supplicant writes:
    ... door on the latch. ... villages. ... slower and slower each day to see how far out it is, ... home at peteward dot gotadsl dot co dot uk ...
    (uk.rec.sheds)
  • Re: Does leather shrink in the dark?
    ... Might be worth buying one of those sprung-exerciser jobbies to build ... but the slower you ride the lower the stresses on your body. ... chris.desclayes at ffcc dot powernet dot co dot uk ...
    (uk.rec.motorcycles)
  • Re: Does leather shrink in the dark?
    ... but the slower you ride the lower the stresses on your body. ... the more weight on your wrists - on a sportsbike. ... chris.desclayes at ffcc dot powernet dot co dot uk ...
    (uk.rec.motorcycles)
  • Re: 6502s and Symbol Tables
    ... mdj wrote: ... The more unique symbols, ... the slower it gets: ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.sys.apple2.programmer)
  • Re: No USB for G3 Beige Box?
    ... Considering the speed of the computer, it won't be much slower ... email to oshea dot j dot j at gmail dot com. ...
    (comp.sys.mac.misc)