## tell me how to calculate histc(x,y)

### BANI tita (view profile)

on 7 Jun 2013

can you tell me how to calculate histc two variable (x and y) in matlab ;thank you

## Products

No products are associated with this question.

on 7 Jun 2013

Azzi Abdelmalek

### Azzi Abdelmalek (view profile)

on 7 Jun 2013

Give a short example

BANI tita

### BANI tita (view profile)

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 (view profile)

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]

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test