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

6 ビュー (過去 30 日間)
Mudasser Seraj
Mudasser Seraj 2020 年 5 月 13 日
コメント済み: Mudasser Seraj 2020 年 5 月 20 日
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 Center および File ExchangeOrange についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by