Error using histc Edge vector must be monotonically non-decreasing.

6 Ansichten (letzte 30 Tage)
Mudasser Seraj
Mudasser Seraj am 13 Mai 2020
Kommentiert: Mudasser Seraj am 20 Mai 2020
Hi
I have the following code and data;
clc
clear all
datapoint = [0; 2; 0; 2; 5; 8; 7; 10; 21; 38; 51; 53; 84; 93; 115; 123; 134];
for j =1:length(datapoint)
value =datapoint(j);
for i = 1:value
xpos(i,j) = 600*rand();
ypos(i,j) = -1.75+ 3.5*rand();
end
end
xpos(xpos==0)=nan;
ypos(ypos==0)=nan;
label = 1200:100:2800;
%% Spatial distribution
for k = 1:17
ax(i) = subplot(1,17,k);
values = hist3([ypos(:,k) xpos(:,k)],[4 60]);
V = values.';
Vq = interp2(V,5);
imagesc(Vq);
%grid on
caxis([0 7]);
if k == 1
axis on
else
set(gca,'yticklabel',{[]})
end
set(gca,'xticklabel',{[]})
xlabel(label(1,k));
end
Once I ran it, I got the error in title. Can someone help me to solve the problem?
I am supposed to get the figure like following. Other codes to plot similar figure can also help.

Antworten (1)

Sindhu Karri
Sindhu Karri am 19 Mai 2020
Hii,
The error is due to following code lines:
xpos(xpos==0)=nan;
ypos(ypos==0)=nan;
By modifying these lines as below
xpos(xpos==0)= 0;
ypos(ypos==0)= 0;
You can avoid the error and get the desired plot
  1 Kommentar
Mudasser Seraj
Mudasser Seraj am 20 Mai 2020
Thank you. I have tried your way. It's generating the image, but now it has another issue for data like
datapoint = [0; 2; 0; 2; 5; 8; 7; 10; 21; 38; 51; 53; 84; 93; 115; 123; 134];
I am getting the following figure with deep yellow at some location, which is unusual.
I don't know why, is there any solution to this?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by