3D Distribution Plot on Matlab

  • MATLAB
  • Thread starter galanos
  • Start date
  • #1
2
0

Main Question or Discussion Point

Im trying to build a Matlab code for the distribution of a parameter (such as density or temperature) in 3D, then visualise the distribution also in 3D. At the end, the distribution plot should look like a cone shape where the highest value for the density (or temperature) is at the tip of the cone and lower values as moving down and outwards on the cone. So that density should decrease both by horizontal and vertical distance from the cone tip. Ive tried Normal (Gausian) distribution for the 2D case and it worked but i dont know how to apply that for 3D case and im really lost!

What im intended to do is to use many equally sized cells (cubes) to define a 3D environment (volume) and then assign values for the density to each of these cells according to a distribution function (normal dist func.)

Here is what ive tried so far for the 2D case. You may see several funny mistakes since im almost a beginner on Matlab! Please give me some idea and light up my world!

% Standard Normal Distribution of Density
clear all,close all
% Parameters:
% x:cell number
% l: total length of cells in a layer
% h: distance from the cone tip
% d_cell: dimension of the cell
% i: layer number
% m: mass in each layer (constant)

theta = pi/10; % cone angle (18 deg)
d_cell = 0.1; % cell dimension
cell_volume = d_cell^3;
mu = 0; % mean value of the normal distribution
m = 0.005; %row mass

symvar h; % symbolic variable
h = 1:60;
l = 2*h*tan(theta/2);
% plot(h,l(h));

% number of cells in each layer:-----------------------------------------
n = l/d_cell;
n = fix((n(h)+1)/2)*2-1; % rounds to the nearest smaller odd number

% standard deviation of the density distribution:------------------------
sigma = [];
sigma(1) = 1;
for j = 2:60
sigma(j) = sigma(j-1)*(n(j)/n(j-1));
end

% normal distribution of density on each layer:--------------------------
x = cell(60,1);
y = cell(60,1);
N = cell(60,1);
coef = cell(60,1);
for i = 1:60
t = (n(i)-1)/2;
x{i,1} = 1:t;
y{i,1} = (exp(-(x{i,1}-mu).^2/(2*(sigma(i)).^2)))./(sigma(i)*sqrt(2*pi));
N{i,1} = y{i,1}/max(y{i,1});
coef{i,1} = m/sum(cell_volume*N{i,1});
N{i,1} = coef{i,1}*N{i,1};
end

plot(x{i,1},N{i,1});

Thanks in advance for any help..
 

Answers and Replies

Related Threads on 3D Distribution Plot on Matlab

Replies
6
Views
25K
  • Last Post
Replies
4
Views
14K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
6
Views
105K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
4
Views
8K
  • Last Post
Replies
2
Views
2K
Replies
3
Views
12K
Replies
4
Views
4K
Top