Re: can matlab plot data by condition



Thank you Titus, your method works and improve the effective
by about 20%.

"Titus" <titus.edelhofer@xxxxxxxxxxxx> wrote in message
<fg9mrn$1jq$1@xxxxxxxxxxxxxxxxxx>...

"Ha Wanger" <virtualcyberinfo+nospam@xxxxxxxxx> schrieb im
Newsbeitrag
news:fg98ea$iv5$1@xxxxxxxxxxxxxxxxxxxxx
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!





Hi,
you have it more or less. I would use
plot(X,Y,'-');
hold on
positive = Y>=0;
plot(X(positive), Y(positive), '.b');
plot(X(~positive), Y(~positive), '.r');

Titus



.



Relevant Pages

  • can matlab plot data by condition
    ... I want to have a line-dot plot and when Y<0, ... Now I'm using the follwing method: ... some inefficient. ...
    (comp.soft-sys.matlab)
  • Re: can matlab plot data by condition
    ... I want to have a line-dot plot and when Y<0, ... Now I'm using the follwing method: ... some inefficient. ...
    (comp.soft-sys.matlab)
  • Re: can matlab plot data by condition
    ... I want to have a line-dot plot and when Y<0, ... Now I'm using the follwing method: ... actually,the matrixs X & Y are very big so this method is ...
    (comp.soft-sys.matlab)
  • Re: can matlab plot data by condition
    ... I want to have a line-dot plot and when Y<0, ... Now I'm using the follwing method: ... Probably there are better ways than this, but hey (X and Y are vectors ...
    (comp.soft-sys.matlab)