Error using histc Edge vector must be monotonically non-decreasing.
3 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Sindhu Karri
on 19 May 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
See Also
Categories
Find more on Orange 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!