how to solve bar Error . Error using bar (line 58) X must be same length as Y.

2 次查看(过去 30 天)
i have this code. last time its work good and but now bar error is shown.
[num,text,raw] = xlsread('Book1.xlsx');
x=num(:,7);
observX = x(1:1000);
imageX=0:23;
nX = length(imageX);
for i = 1:nX
cX = imageX(i);
cntX(i) = sum(observX == cX);
end
pmfX = cntX/sum(cntX);
figure;
bar(imageX, pmfX);
title('Marginal PMF Of "O3.1st.Max.Hour"')
xlabel('Image Of O3.1st.Max.Hour')
ylabel('Marginal PMF')
figure;
bar(imageX, cntX);
title('Histogram Of "O3.1st.Max.Hour"');
xlabel('Image Of O3.1st.Max.Hour');
ylabel('Counts of Occurence');
Error using bar (line 58) X must be same length as Y.
  5 个评论
KSSV
KSSV 2018-12-27
编辑:KSSV 2018-12-27
Error is clear the inputs of bar are of not same dimensions.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2018-12-27
Try:
x=num(:,2); % or x=num(:,1); %
As you have used
x=num(:,7);
I suspect.....one of the input to bar is empty or NaN...so the error.

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by