フィルターのクリア

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

1 回表示 (過去 30 日間)
Dhines
Dhines 2013 年 1 月 11 日
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 件のコメント
Dhines
Dhines 2013 年 1 月 17 日
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 2013 年 1 月 17 日
What does "is not working" mean? Do you get an error message or do the results differ from your expectations?

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 1 月 11 日
Why are you setting b(i,j)=0 inside each "for v" iteration ?

Andrei Bobrov
Andrei Bobrov 2013 年 1 月 11 日
編集済み: Andrei Bobrov 2013 年 1 月 11 日
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
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 1 月 11 日
The p1 computation could be moved to prior to the "for jj" loop.
Andrei Bobrov
Andrei Bobrov 2013 年 1 月 11 日
Hi Walter! I agree with you, corrected.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by