tell me how to calculate histc(x,y)

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

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 7 Jun. 2013

0 Stimmen

4 Kommentare

BANI tita
BANI tita am 7 Jun. 2013
Bearbeitet: Azzi Abdelmalek am 7 Jun. 2013
when I did, it gave me an error message: ?? Error using ==> histc Edge vector must be monotonically non-decreasing.
==========
Freq = zeros(Lx,Ly);
edges{1}= minIntervalx; edges{2} = minIntervaly;
Freq = histc(y(:),x(:),edges);
Azzi Abdelmalek
Azzi Abdelmalek am 7 Jun. 2013
Give a short example
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 am 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]

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 7 Jun. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by