joint pdf calculation and plot

조회 수: 8 (최근 30일)
Yusuf
Yusuf 2015년 9월 10일
Hi guys,
Having a bit of trouble trying to make a file that calculates and plot the join pdf of 2 variables using 100 bins.
Current attempt which I'm not sure is the best way to go about it
x = A.data(1:57199,2); %gather x data y = A.data(1:57199,3); %gather y data
x_axis = 1:100:57199; % Define edges of bins for x axis. Column vector y_axis = 1:100:57199; % Same for y axis
% Compute corners of 2D-bins: [x_mesh_upper,y_mesh_upper] = meshgrid(x_axis(2:end),y_axis(2:end)); [x_mesh_lower,y_mesh_lower] = meshgrid(x_axis(1:end-1),y_axis(1:end-1));
% Compute centers of 1D-bins: x_centers = (x_axis(2:end)+x_axis(1:end-1))/2; y_centers = (y_axis(2:end)+y_axis(1:end-1))/2;
% Compute pdf: pdf = mean( bsxfun(@le, x(:), x_mesh_upper(:).') ... & bsxfun(@gt, X(:), x_mesh_lower(:).') ... & bsxfun(@le, Y(:), y_mesh_upper(:).') ... & bsxfun(@gt, Y(:), y_mesh_lower(:).') ); pdf = reshape(pdf,length(x_axis)-1,length(y_axis)-1); % pdf values at the % grid points defined by x_centers, y_centers pdf = pdf ./ (y_mesh_upper-y_mesh_lower) ./ (x_mesh_upper-x_mesh_lower); % normalize pdf to unit integral
% Plot pdf figure imagesc(x_centers,y_centers,pdf) axis xy axis equal colorbar title 'pdf'
Thanks in advance guys!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by