フィルターのクリア

how to update the step size in my code ?

1 回表示 (過去 30 日間)
kitty varghese
kitty varghese 2017 年 9 月 6 日
コメント済み: KL 2017 年 9 月 8 日
This is a dummy program. I want to update the values of stepsize1 and stepsize2 such that my error<0.5. I have coded something but I'm unable to update the new value.
if true
A=[25 30 47 58;11 25 87 98;77 44 85 23;97 48 25 14];
B=[1 5;5 1;7 7;9 8];
C=[74 2 11 7;5 6 9 9];
stepsize1=1;
stepsize2=1;
B1=stepsize1*B;
C1=stepsize2*C;
W=B1*C1;
error=pdist2(A,W,'euclidean');
if error<0.5
break
else stepsize1=stepsize1+0.1;
stepsze2=stepsize2+0.1;
end
end

回答 (1 件)

KL
KL 2017 年 9 月 6 日
Something like this??
A=[25 30 47 58;11 25 87 98;77 44 85 23;97 48 25 14];
B=[1 5;5 1;7 7;9 8];
C=[74 2 11 7;5 6 9 9];
stepsize1=0.9;
stepsize2=0.9;
error_val = 1; %dummy
while error_val>0.5
stepsize1=stepsize1+0.1;
stepsze2=stepsize2+0.1;
B1=stepsize1*B;
C1=stepsize2*C;
W=B1*C1;
error_val=pdist2(A,W,'euclidean')
end
  2 件のコメント
kitty varghese
kitty varghese 2017 年 9 月 8 日
why did you use error_val=1;
KL
KL 2017 年 9 月 8 日
while loop checks condition (in this case, error_val>0.5) at the start, so we just need something more than 0.5 so the loop is executed at least once to calculate the actual value of the error_val. Then the loop is repeated until this condition becomes false.

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

カテゴリ

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