MATLAB: Scatter plot – plot different symbols when data is negative

plotscatter

Greetings all,
I'm trying to differentiate positive and negative data on a plot by representing it with different symbols (i.e. 'o' and 'x', wheere the 'x' would represent negative data), but I'm not having any luck with it.
Here's what I tried:
figure(4)
scatter(sigma2new_Case1,sigma1new_Case1)
while(sigma2new_Case1 < 0)
plot(sigma2new_Case1,sigma1new_Case1,'x');
end
The statement in the "while" – I tried scatter in there but it didn't make any difference – I still get a plot full of 'o's.
Obviously I'm doing something wrong, and if someone could provide suggestions that would be greatly appreciated.
Thanks! Jesse

Best Answer

well what you're missing is any indexing inside your while loop to check which are less than 0 and basically comparing all of sigma2new_Casel to be <0. You can first figure out which items are <0 and then just plot each one. something like this
y=randi(10,1,20)-5;
x = 1:20;
neg = y<0;
figure,plot(x(~neg),y(~neg),'+',x(neg),y(neg),'o')