joint pdf calculation and plot

8 visualizaciones (últimos 30 días)
Yusuf
Yusuf el 10 de Sept. de 2015
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!

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by