x,y,z plot and temperature

16 次查看(过去 30 天)
Hi,
I am interested in visualizing temperature distribution on a 3D plot like point.
I have a 3d path, for each point I have x,y,z coordinates for its position and corresponding temperature. the coordinates are "x" "y" "z" and the temperature "temperature".
How can I draw a 3d-plot from these x,y,z and color them with my temperature value?
Thanks.

采纳的回答

Honglei Chen
Honglei Chen 2017-12-12
Is it something like this?
x = rand(100,1);
y = rand(100,1);
z = rand(100,1);
t = rand(100,3);
scatter3(x,y,z,20,t);
HTH

更多回答(1 个)

Image Analyst
Image Analyst 2017-12-12
Try this:
% Make sample parameterized curves for test data.
t = 1 : 100
x = cosd(t);
y = sind(t);
z = t/50;
minTemperature = 20;
maxTemperature = 80;
% Say that temps are random int he range of 20 to 80 degrees.
temperature = minTemperature + (maxTemperature - minTemperature) * rand(1, length(t));
% Now we have our sample/test data, and we can begin.
% First create a colormap.
numPoints = length(x);
cmap = hsv(numPoints);
% Now we need to make those temperatures into a colormap.
% First take temperatures and make it so that minTemperature is an index of 1
% and the max Temperature is an index of length(x);
minTemperature = min(temperature);
maxTemperature = max(temperature);
% Get a percentage of the way the temperatures are from max to min.
percentage = (maxTemperature - temperature) / (maxTemperature - minTemperature)
% Find the index for each temperature in the range 1 to the number of colors in our colormap.
indexes = round(percentage * (numPoints - 1) + 1);
tempColors = cmap(indexes, :);
scatter3(x, y, z, 14, tempColors, 'filled');
The color of each dot is related to what temperature it is.

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by