Effacer les filtres
Effacer les filtres

x,y,z plot and temperature

7 vues (au cours des 30 derniers jours)
Michela Longhi
Michela Longhi le 12 Déc 2017
Commenté : Michela Longhi le 13 Déc 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.

Réponse acceptée

Honglei Chen
Honglei Chen le 12 Déc 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
  1 commentaire
Michela Longhi
Michela Longhi le 13 Déc 2017
Thank you for the answer!

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 12 Déc 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.
  1 commentaire
Michela Longhi
Michela Longhi le 13 Déc 2017
Thank you for the great example!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by