How to assign a color to zeros in a matrix.

2 views (last 30 days)
Hello, I have a problem, how to assign a color to zeros in a matrix, for example:
zeros = Z == 0;
Z (zeros) = NaN;
But I want to assign a color to NaN in the graph, how is this possible. regards
  6 Comments
Guillaume
Guillaume on 13 Mar 2018
It's my personal opinion, so take it for whatever it's worth, but I'd prefer if you didn't delete your answers so often. Even if they may not answer the actual questions (which are often ambiguous anyway), they still provide some useful information.
Birdman
Birdman on 13 Mar 2018
I don't want my answer to be a junk between other answers if it is out of topic, therefore I find it useful to delete them and so the readers will confuse less.

Sign in to comment.

Accepted Answer

Birdman
Birdman on 13 Mar 2018
When you say assigning colors to zeros, I thought of assigning them while plotting. Consider a simple example:
x=1:10;
y=[2 4 5 6 0 0 0 3 2 4];
plot(x,y);hold on;
plot(x(y==0),y(y==0),'color','r','marker','o');

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!