categorical histograms: combining missing category values
2 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Azzi Abdelmalek
on 30 Jul 2014
Edited: Azzi Abdelmalek
on 30 Jul 2014
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 Comments
More Answers (0)
See Also
Categories
Find more on Histograms 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!