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

3 次查看(过去 30 天)
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.

回答(1 个)

Sindhu Karri
Sindhu Karri 2020-5-19
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 个评论
Mudasser Seraj
Mudasser Seraj 2020-5-20
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by