Clear Filters
Clear Filters

x,y,z plot and temperature

7 views (last 30 days)
Michela Longhi
Michela Longhi on 12 Dec 2017
Commented: Michela Longhi on 13 Dec 2017
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.

Accepted Answer

Honglei Chen
Honglei Chen on 12 Dec 2017
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

More Answers (1)

Image Analyst
Image Analyst on 12 Dec 2017
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.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!