How to normalize surface such that area under surface=1?
Show older comments
I'm trying to plot surface such that area under the surface is equal to 1. I'm using 50x50 histogram (with values from 0 to around 16) to plot a surface which represents probability density distribution. I'm having a hard time to crack this problem and I have absolutely no idea how to normalize my data. Fragment of code below:
dr = 50; % surface 50x50
r = 5;
% yafter and zafter are coordinates of a molecule, there are around 1000
% positions of those and I only wrote below some examples of those
% positions for better understanding of the code, since writing down
% the whole program would be pointless
yafter = [0.5603 0.5603];
zafter = [0.8458 0.8458];
N = 2; % number of molecules
for ii=1:N
position_y = round((yafter(ii)+(2.*r)./dr./2)./(2.*r).*dr)+dr./2+1;
position_z = round((zafter(ii)+(2.*r)./dr./2)./(2.*r).*dr)+dr./2+1;
histogram(position_y, position_z) = (histogram(position_y, position_z) + 1);
end
figure(3)
hold on
view(3);
surf(histogram);
colormap autumn;
title('Probability density distribution after 10000 steps', 'FontSize', 14);
xlabel('Y', 'FontSize', 24, 'fontweight', 'bold');
ylabel('Z', 'FontSize', 24, 'fontweight', 'bold');
zlabel('P(Y,Z)', 'FontSize', 24, 'fontweight', 'bold');
set(gca, 'FontSize', 16);
axis([0 dr 0 dr]);
hold off
Answers (0)
Categories
Find more on Blue 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!