Info
This question is closed. Reopen it to edit or answer.
Plotting a data from a matrix
1 view (last 30 days)
Show older comments
Hi I have a matrix where there are 11 rows and 198 columns. The values range between -1 to +1. I would like to plot the values (1 to 198 on x axis and 11 (random 11 sets)) in such a way that the positive values get red colour and the negative values get blue colour. How do I go about it? Thanks
0 Comments
Answers (1)
Walter Roberson
on 2 Jun 2015
colidx = 1 + (YourMatrix >= 0);
surf(YourMatrix, colidx);
colormap([0 0 1; 1 0 0]); %blue; red
If you are thinking of a line plot then you need to define what should happen for lines that go between positive and negative points. You might want
mesh(YourMatrix, colidx);
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!