Change axis color on parts of the mesh

6 visualizaciones (últimos 30 días)
Alexandra Roxana
Alexandra Roxana el 18 de Sept. de 2022
Comentada: Voss el 19 de Sept. de 2022
I would like this plot to have 2 colors on the same surface, meaning: blue between the x values of 1 and 2 and then between 9 and 10 and red on the rest of it.
Here's the code:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)

Respuesta aceptada

Voss
Voss el 18 de Sept. de 2022
Editada: Voss el 18 de Sept. de 2022
Here's one way:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
C = 1 + (X <= 2 | X >= 9);
surf(X,Y,Z,C)
colormap([1 0 0; 0 0 1]);
  2 comentarios
Alexandra Roxana
Alexandra Roxana el 18 de Sept. de 2022
Great and easy! Thanks a lot!
Voss
Voss el 19 de Sept. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by