Dimensions of arrays being concatenated are not consistent.

조회 수: 2 (최근 30일)
gjashta
gjashta 2019년 5월 8일
댓글: Matt J 2019년 5월 9일
I want to bin the price values in 5 bins and for each bin to group the demand values AND
then calculate the mean and the standard deviation of the demand data for each bin.
Could you please help me to fix the code?
I am trying with the following code but I got this error:
Dimensions of arrays being concatenated are not consistent.
p=Data(:,1);
d=Data(:,2);
partitions = [0 40; 40 55; 55 65; 65 max(x)+1];
for k1 = 1:size(partitions,1)
ypartmean(k1) = mean(di((pi >= partitions(k1,1)) & (pi < partitions(k1,2))));
binct(k1) = numel(di((pi >= partitions(k1,1)) & (pi < partitions(k1,2))));
end

채택된 답변

Matt J
Matt J 2019년 5월 8일
편집: Matt J 2019년 5월 8일
No need to loop,
E=[0,40,65,55,inf];
[binct,~,G]=histcounts(p,E);
ypartmean=splitapply(@mean,d,G);
  댓글 수: 10
gjashta
gjashta 2019년 5월 8일
I got an error with scatter plot because EPSs above are vectors with different length.
Matt J
Matt J 2019년 5월 9일
You certainly should reorganize your data into a form that scatter() expects.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axes Transformations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by