Borrar filtros
Borrar filtros

this code is not working for transition probability matrix ....make it correct?

1 visualización (últimos 30 días)
my transition probability matrix equation is given under link. http://latex.codecogs.com/gif.latex?p1_{h}(i,j)=\frac{\sum_{u=1}^{S_{u}-2}\sum_{v=1}^{S_{v}}\delta%20(F_{h}(u,v)=i,{F_{h}}(u+1,v)=j)}{\sum_{u=1}^{^{S_{u}-2}}%20\sum_{v=1}^{^{S_{v}}}\delta%20({F_{h}(u,v)=i})}
for this eqn i wrote code given below
sv=128;
su=128;
for i=1:9
for j=1:9
a(i,j)=0;
for u=1:su-2
for v=1:sv
if (Yh(u,v)==i && Yh(u+1,v)==j)
dell=1;
else
dell=0;
end
a(i,j)=a(i,j)+dell;
b(i,j)=0;
if(Yh(u,v)==i)
dell1=1;
else
dell1=0;
end
b(i,j)=b(i,j)+dell1;
end
end
end
end
.....the final result want to know for above code is p=a./b.... and here the dell value as considered as dell(.)=1 if and only if its argumens are satisfied, otherwise dell(.)=0.
  2 comentarios
Dhines
Dhines el 17 de En. de 2013
please check it ..this is another eqn<http://latex.codecogs.com/gif.latex?P1v(i,j)=\frac{{\sum_{u=1}^{^{S_{u}-1}}\sum_{v=1}^{S_{v}-1}\delta%20({F_{h}(u,v)=i,{F_{h}(u,v+1)=j}})}}{\sum_{u=1}^{{S_{u}-1}}\sum_{v=1}^{S_{v}-1}\delta%20(F_{h}(u,v)=i)}>..... i wrote code for this eqn is p1v=zeros(9); for ii=1:9 p1=Yh(1:end-1,:)==ii; for jj=1:9 p2=Yh(:,2:end-1)==jj; p1v(ii,jj) = nnz(p1 & p2)./nnz(p1); end end ...is it correct ?
Jan
Jan el 17 de En. de 2013
What does "is not working" mean? Do you get an error message or do the results differ from your expectations?

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 11 de En. de 2013
Why are you setting b(i,j)=0 inside each "for v" iteration ?

Andrei Bobrov
Andrei Bobrov el 11 de En. de 2013
Editada: Andrei Bobrov el 11 de En. de 2013
p1h = zeros(9);
for ii = 1:9
p1 = Yh(1:end-2,:) == ii;
for jj = 1:9
p2 = Yh(2:end-1,:) == jj;
p1h(ii,jj) = nnz(p1 & p2)./nnz(p1);
end
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by