Change axis color on parts of the mesh

2 visualizzazioni (ultimi 30 giorni)
Alexandra Roxana
Alexandra Roxana il 18 Set 2022
Commentato: Voss il 19 Set 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)

Risposta accettata

Voss
Voss il 18 Set 2022
Modificato: Voss il 18 Set 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]);

Più risposte (0)

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by