Re: can matlab plot data by condition
- From: "Ha Wanger" <virtualcyberinfo+nospam@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 13:18:50 +0000 (UTC)
Thank you Titus, your method works and improve the effective
by about 20%.
"Titus" <titus.edelhofer@xxxxxxxxxxxx> wrote in message
<fg9mrn$1jq$1@xxxxxxxxxxxxxxxxxx>...
Newsbeitrag
"Ha Wanger" <virtualcyberinfo+nospam@xxxxxxxxx> schrieb im
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
.
- References:
- can matlab plot data by condition
- From: Ha Wanger
- Re: can matlab plot data by condition
- From: Titus
- can matlab plot data by condition
- Prev by Date: Re: reading data from text file
- Next by Date: Printing large figure to file
- Previous by thread: Re: can matlab plot data by condition
- Next by thread: Re: can matlab plot data by condition
- Index(es):
Relevant Pages
|