![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276792/image.png)
How to obtain a surface curve plane located on specific heights and with a different vector of color representation?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Philippe Corner
am 12 Mär. 2020
Kommentiert: Philippe Corner
am 12 Mär. 2020
level is a (120,4) matrix. The columns correspond from 1 to 4 to X coordinate, Y coordinate, Z coordinate and a C scalar value.
When I use this code:
x = level(:,1);
y = level(:,2);
z = level(:,3);
xv = linspace(min(level(:,1)), max(level(:,1)), 20);
yv = linspace(min(level(:,2)), max(level(:,2)), 20);
[X,Y] = meshgrid(xv, yv);
Z = griddata(x,y,z,X,Y);
hold on
surf(X, Y, Z);
grid on
shading interp
axis equal
colorbar
I obtain this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276704/image.png)
I would like to obtain a surface which is located exactly as I located this one, following the Z values of hight, but that the colors represent C values and not Z.
The colors of the surf plot should be folliwng this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276705/image.png)
Any ideas about how to do it?
0 Kommentare
Akzeptierte Antwort
darova
am 12 Mär. 2020
Use cdata property
[x,y,z] = peaks(20);
c = sphere(19);
surf(x,y,z,'cdata',c)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276792/image.png)
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!