From: CNN on 27 Jul 2010 08:17 Good day, I'm plotting a series of graphs from data in a .dat file containing thousands of data, some positive, some negative in value. I want to put an label/annotation indicating the percentage of points that are positive and negative. Any suggestion will be helpful.
From: us on 27 Jul 2010 08:24 "CNN " <cnln2000(a)yahoo.co.uk> wrote in message <i2mio0$kou$1(a)fred.mathworks.com>... > Good day, > I'm plotting a series of graphs from data in a .dat file containing thousands of data, some positive, some negative in value. I want to put an label/annotation indicating the percentage of points that are positive and negative. > Any suggestion will be helpful. a hint: help sum; help text; help legend; us
From: CNN on 27 Jul 2010 08:57 'sum' will add the values of the data. I need to know the number of data that are positive and the number that are negative. And I can't use legend because I can only have one legend and I'll need 4 notations. I was planning to use the function 'text' as soon as I figure it out. "us " <us(a)neurol.unizh.ch> wrote in message <i2mj54$h4d$1(a)fred.mathworks.com>... > "CNN " <cnln2000(a)yahoo.co.uk> wrote in message <i2mio0$kou$1(a)fred.mathworks.com>... > > Good day, > > I'm plotting a series of graphs from data in a .dat file containing thousands of data, some positive, some negative in value. I want to put an label/annotation indicating the percentage of points that are positive and negative. > > Any suggestion will be helpful. > > a hint: > > help sum; > help text; > help legend; > > us
From: us on 27 Jul 2010 09:01 On Jul 27, 2:57 pm, "CNN " <cnln2...(a)yahoo.co.uk> wrote: > 'sum' will add the values of the data. I need to know the number of data that are positive and the number that are negative. And I can't use legend because I can only have one legend and I'll need 4 notations. I was planning to use the function 'text' as soon as I figure it out. > > > > "us " <u...(a)neurol.unizh.ch> wrote in message <i2mj54$h4...(a)fred.mathworks.com>... > > "CNN " <cnln2...(a)yahoo.co.uk> wrote in message <i2mio0$ko...(a)fred.mathworks.com>... > > > Good day, > > > I'm plotting a series of graphs from data in a .dat file containing thousands of data, some positive, some negative in value. I want to put an label/annotation indicating the percentage of points that are positive and negative. > > > Any suggestion will be helpful. > > > a hint: > > > help sum; > > help text; > > help legend; > > > us- Hide quoted text - > > - Show quoted text - well... SUM works perfectly well... one of the solutions - a hint: use logical indexing... v=-3:5; sneg=sum(v<0) % sneg = 3 spos=sum(v>0) % spos=5 us
From: CNN on 27 Jul 2010 09:49
us <us(a)neurol.unizh.ch> wrote in message <c1d25ce5-d43a-4eab-a954-eda4ff332543(a)w30g2000vbs.googlegroups.com>... > On Jul 27, 2:57 pm, "CNN " <cnln2...(a)yahoo.co.uk> wrote: > > 'sum' will add the values of the data. I need to know the number of data that are positive and the number that are negative. And I can't use legend because I can only have one legend and I'll need 4 notations. I was planning to use the function 'text' as soon as I figure it out. > > > > > > > > "us " <u...(a)neurol.unizh.ch> wrote in message <i2mj54$h4...(a)fred.mathworks.com>... > > > "CNN " <cnln2...(a)yahoo.co.uk> wrote in message <i2mio0$ko...(a)fred.mathworks.com>... > > > > Good day, > > > > I'm plotting a series of graphs from data in a .dat file containing thousands of data, some positive, some negative in value. I want to put an label/annotation indicating the percentage of points that are positive and negative. > > > > Any suggestion will be helpful. > > > > > a hint: > > > > > help sum; > > > help text; > > > help legend; > > > > > us- Hide quoted text - > > > > - Show quoted text - > > well... SUM works perfectly well... > > one of the solutions > - a hint: use logical indexing... > > v=-3:5; > sneg=sum(v<0) > % sneg = 3 > spos=sum(v>0) > % spos=5 > > us Ok I'm kind of surprised. I thought sum adds up the values of data in a matrix/array or am I mistaken? And I'm fairly new to MATLAB so I have no idea how to go about the logical indexing. I though about using the function 'size' but how to make it check the data for positive or negative values, that I've not figured it out yet. Would posting my code help? |