mirage
mirage

Reputation: 145

How to assign values to particular point in 3D rectangle in matlab

I want to animate the varying temperature gradient in 3D rectangle. I have temperature values at specified points in a real container. I am not been able to figure out how to pass the temperature values as specified point in 3D container in Matlab.Lets say I have 10 points on one side of rectangle and same as on other remaining five sides. any suggestions

Upvotes: 0

Views: 829

Answers (2)

yuk
yuk

Reputation: 19880

Let's assume that your rectangular container is oriented in space with one vertex at (0,0,0) and sides along x, y and z axis. And you have set of points each with 3-point coordinate (x,y,z). In MATLAB it's probably represented by 3 vectors X, Y and Z. You also have a vector of temperature values (say T) for each points.

Then you can use SCATTER3 function to plot the points:

scatter3(X,Y,Z,[],T,'.')

You can change the size of points substituting the empty parameter with a value.

If you have point only on the faces of the container, it means one of the coordinate is either 0 or the size of corresponding side.

the colors are controlled by current color map. You can change it with COLORMAP function. For temperature the good one is 'hot' or 'cool'. Show the color scale with COLORBAR.

Here is an example with random data:

%# random coordinates
X = rand(60,1,1);
Y = rand(60,1,1);
Z = rand(60,1,1);

%# put the points into faces
X(1:10) = 0;
X(10:20) = 1;
Y(20:30) = 0;
Y(30:40) = 1;
Z(40:50) = 0;
Z(50:60) = 1;

%# temperature vector
T = rand(60,1,1) * 100;

%# plot
scatter3(X,Y,Z,[],T,'.')
grid off
box on
colormap hot
colorbar

Upvotes: 1

Oli
Oli

Reputation: 16055

Temp=zeros(10,10,10);
Temp(5,2,4)=25;

Upvotes: 0

Related Questions