plot vector where negative data is circled

If I e.g. have the following two vectors:
data = [1 2 3 -4 -5 6 -7 8 9 -10]
pos = [1 2 3 4 5 6 7 8 9 10]
How can I do
plot(abs(data),pos)
set(gca,'xscale','log');
where only the negative data is circled? Is that even possible without stepping through each data point?

 Akzeptierte Antwort

Rick Rosson
Rick Rosson am 13 Mär. 2015
Bearbeitet: Rick Rosson am 13 Mär. 2015

0 Stimmen

isNeg = (data < 0);
plot(abs(data),pos)
hold on
plot(abs(data(isNeg)),pos(isNeg),'o')
set(gca,'xscale','log');

Weitere Antworten (1)

Toke Søltoft
Toke Søltoft am 13 Mär. 2015

0 Stimmen

thanks so much. Works like a charm.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by