categorical histograms: combining missing category values

조회 수: 3 (최근 30일)
g
g 2014년 7월 30일
댓글: g 2014년 7월 30일
hello,
let say i have categorical data1 which is in histogram form values, counts and a 2nd histogram with its own counts, values. each has similar bins but each are missing values from each other.
how do i fill in each other missing category values?
example
data 1 categories {'a' 'b' 'm' 'u' 'z'} counts[10 4 12 23)
data 2 categories {'a' 'aa' 'b' 'e'} counts(2 1 5 7)
final result
data 1 categories {'a' 'aa' 'b' 'e' 'm' 'z'} counts(10 0 4 0 12 23)
data 2 categories {'a' 'aa' 'b' 'e' 'm' 'z'} counts(2 1 5 7 0 0)
thanks for any help.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 30일
편집: Azzi Abdelmalek 2014년 7월 30일
a1={'a' 'b' 'm' 'z'};
b1=[10 4 12 23];
a2={'a' 'aa' 'b' 'e'};
b2=[2 1 5 7];
c=unique([a1 a2]);
data1=zeros(1,numel(c));
data2=data1;
data1(ismember(c1,a1))=b1
data2(ismember(c1,a2))=b2
  댓글 수: 4
Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 30일
What your comment has to do with your original question?
g
g 2014년 7월 30일
obviously there seemed to be an error
'c1' should be 'c'
i fixed it and it works.
thanks for the help.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by