tell me how to calculate histc(x,y)

1 view (last 30 days)
BANI tita
BANI tita on 7 Jun 2013
can you tell me how to calculate histc two variable (x and y) in matlab ;thank you

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 7 Jun 2013
  4 Comments
BANI tita
BANI tita on 7 Jun 2013
x=[1 3 3 ;3 2 3; 1 2 1;3 2, 4; 5 5 1]
y=[1; 2; 3;4;5]
for k=1:3
Mux(k,:)=mean(x(y==k,3));
Muy(k,:)=mean(y==k,1);
Sigmax(k,:) = std(x(y==k,3));
Sigmay(k,:) = std(y==k,1);
end
% return
a=2;
[tmpx, idx]=sort(Mux);
[tmpy, idy]=sort(Muy);
MumoinsSigmax = Mux(idx,:)-a*Sigmax(idx,:),;
MuplusSigmax = Mux(idx,:)+a*Sigmax(idx,:),;
MumoinsSigmay = Mux(idy,:)-a*Sigmax(idy,:),;
MuplusSigmay = Mux(idy,:)+a*Sigmax(idy,:),;
minIntervalx = [-Inf,MumoinsSigmax:MuplusSigmax],;
minIntervaly = [-Inf,MumoinsSigmay:MuplusSigmay],;
minIntervalx = [minIntervalx,Inf],;
minIntervaly = [minIntervaly,Inf],;
Lx = length(minIntervalx),; Ly = length(minIntervaly),;
Freq = zeros(Lx,Ly);
edges= {minIntervalx,minIntervaly}
Freq = histc(y(:),x(:),edges);
BANI tita
BANI tita on 7 Jun 2013
replace x and y with:
x=[1 3 3 ;3 2 3; 1 2 1;3 2, 3; 3 2 1]
y=[1; 1; 3;3;2]

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!