1. 매트랩에서 제공하는 hist3를 사용하기
a. 실행 화면
b. 소스
% 1. Data to plot
x = randn(10000, 1);
y = randn(10000, 1);
% 2. Range and resolution of histogram
LL=-10; % Lower Limit
UL=10; % Upper Limit
dt = 0.5; % Delta t
SHIFTv = 0;
SHIFTw = 0;
v = LL - SHIFTv : dt : UL - SHIFTv ;
w = LL - SHIFTw : dt : UL - SHIFTw ;
% 3. Plot specifics
figure(1);
hist3([x y], {v w});
xlabel('x');
ylabel('y');
zlabel('Probability');
title('3D Histogram');
set(gcf,'renderer','opengl');
set(get(gca,'child'),'FaceColor','interp','CDataMode','auto');
2. surf를 이용한 3d 히스토그램 그리기
a) 실행화면
b) 소스
% 1. Data to plot
x = randn(10000, 1);
y = randn(10000, 1);
[sizex1 sizex2] = size(x);
[sizey1 sizey2] = size(y);
% 2. Range and resolution of histogram
LL = -10; % Lower Limit
UL = 10; % Upper Limit
dt = 0.3; % Delta t
SHIFTv = 0;
SHIFTw = 0;
v = LL - SHIFTv : dt : UL - SHIFTv ;
w = LL - SHIFTw : dt : UL - SHIFTw ;
[X,Y] = meshgrid(v,w);
% 3. Plot specifics
figure(2)
pdfz1 = hist3([x y], {v w});
pdfz1 = pdfz1'/sizex1; %!!!!!!!! Transpose pdfz!!!!
surf(X , Y, pdfz1)
xlabel('X');
ylabel('Y');
zlabel('Probability Mass');
title('Joint Probability Mass');
3. hist2d 함수 사용하기 (custom made)
a) 실행화면
b) 소스
% 1. Data to plot
x_1 = randn(1000, 1); % data for testing hist2d fucnctioni
x_2 = randn(1000, 1);
X_1 = x_1;
X_2 = x_2;
mYX = [X_1 , X_2];
% 2. Range and resolution of histogram
vXEdge = linspace(-3, 3, 20); % min, max, resolution respectively
vYEdge = linspace(-3, 3, 20);
% 3. Plot specifics
mHist2d = hist2d(mYX, vYEdge, vXEdge);
nXBins = length(vXEdge);
nYBins = length(vYEdge);
vXLabel = 0.5*(vXEdge(1:(nXBins-1))+vXEdge(2:nXBins));
vYLabel = 0.5*(vYEdge(1:(nYBins-1))+vYEdge(2:nYBins));
pcolor(vXLabel, vYLabel,mHist2d); colorbar
'Enginius > Matlab' 카테고리의 다른 글
max (find maximum values in matrix) (0) | 2012.06.11 |
---|---|
image (rgb2gray, im2bw, edge) (0) | 2012.06.05 |
Matlab에서 "Out of Memory" 해결하기 (5) | 2012.05.24 |
newff (0) | 2011.11.07 |
syms + ezplot = rocks! (0) | 2011.10.27 |