MATLAB Answers

How to assign to an already 3d surface a colormap based on a set of values ?

3 ビュー (過去 30 日間)
Marco Artiano
Marco Artiano 2019 年 10 月 16 日
Commented: Marco Artiano 2019 年 10 月 16 日
Hi guys, let imagine that I've already plotted a 3d surface, let be for reason of simplification a semicylinder (so displayed as a function using surf). Now I want to modify every single point/(piece of surface) color of this surface based on a set of value, for example I have computed the temperature point to point on that surface, now I just want to show that variation on the surface, in the sense of colormap. I know that it is possibe doing this with a 2D plot, simply by plotting the matrix of Temperature on a surf(T) and see the plot from the top, but I would like to see that on the geometry.

  0 件のコメント

サインイン to comment.

採用された回答

Fabio Freschi
Fabio Freschi 2019 年 10 月 16 日
編集済み: Fabio Freschi 2019 年 10 月 16 日
Not sure if I have understood correctly. I try. I assume that you have the temperature plot as 2d matrix, as required by surf, because you mentioned it.
% data for the surface
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
% original temperature
T0 = X; % dummy temperature map
% first plot
figure
% plot with surf, saving the surface object in 's'
s = surf(X,Y,Z,T0);
Then you evaluate a new temperature, for example T1
% new temperature
T1 = Y; % new dummy temperature map
Now you can change the temperaure map by accessing the CData field in s
s.CData = T1;

  1 件のコメント

Marco Artiano
Marco Artiano 2019 年 10 月 16 日
Thank you so much, I had to just put the matrix of temperature that I had in place of T0. It worked perfectly !

サインイン to comment.

More Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 10 月 16 日
編集済み: Bjorn Gustavsson 2019 年 10 月 16 日
This is how I'd do this:
surf(x,y,z,Temps),shading flat
This you dont have to view from above.
HTH

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ

製品


リリース

R2019a

Translated by