Why I am getting "Vector X must be strictly increasing or strictly decreasing with no repeated values" error while plotting contour of joint probability distribution?!

9 views (last 30 days)
HI. I am trying to plot a joint distribution for xi and yi which are numbers and independent. (something like the image). Size of both xi and yi is 6980*1 that is why I put 6980 for bins in hist3(). I get this error and I don’t know how to fix it. Do you have any recommendation?
Error using contour (line 53)
Vector X must be strictly increasing or strictly decreasing with no repeated values.
Error in new (line 24)
contour(xi,yi,pdfData,'ShowText','on','LineWidth', 1.5);
%% Data :
xi = xlsread('All.xlsx',1,'B:B');
yi = xlsread('All.xlsx',1,'C:C');
%% hist3 will bin the data
hst = hist3([xi,yi],'Nbins',[6980 6980]);
%% histogram data
dx = xi(2)-xi(1);
dy = yi(2)-yi(1);
area = dx*dy;
pdfData = hst/sum(sum(hst))/area;
%% plot pdf
figure(1); clf
contour(xi,yi,pdfData,'ShowText','on','LineWidth', 1.5);
c = colorbar;

Answers (0)

Categories

Find more on Contour Plots 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!