I'm trying to generate two surface plots with where the same value in z-direction gets the same color for each plot. I managed to asign the colors for one plot, but they are not consistent to the next one. E.g. z=8 in 1st plot is green and in the 2nd plot is z=8 blue, but I want it to stick to green. It is visible on the picture. The 2nd picture will only scale from 8 to 10, so I can't put a 0 in somewhere to get the same z-axis settings.
close all; clc; clear all; %#okcla
% Define the vectors
x = [1 2 ];y = [1 2 3 4 5 6 7 8 9 10];z = [0 0; 0 0; 0 0; 8 8; 8 8; 8 8; 10 10; 10 10; 10 10; 10 10];z2 = [10 10; 10 10; 8 8; 8 8; 8 8; 8 8; 10 10; 10 10; 10 10; 10 10];C = zeros(size(z));% asign values for the colormap
C(z == 0) = 1;C(z == 8) = 2;C(z == 10) = 3;% Define the colors used by the colormap
cmap = [0 1 0; 0 0 1; 1 0 0];% plot it
figuresurf(x,y,z,C);% Repeat for 2nd plot
D = zeros(size(z2));D(z2 == 0) = 1;D(z2 == 8) = 2;D(z2 == 10) = 3;cmap = [0 1 0; 0 0 1; 1 0 0];figuresurf(x,y,z2,D);
I'd be grateful for any hints :)Cheers Christoph
Best Answer