How to update variable content for every iteration?
古いコメントを表示
hi everyone. i need some help regarding to my code which is as follow. this is what i am doing initially i have assume the value ti0 and tb0. after some process new ti1 and tb1 is calculated the problem which i am facing is that i have to update tb0 and ti0 with this new value until it reaches to 1. hope i can get some help with this
while(ti0<=1&&tb0<=1)
tin=0;
tbn=0;
p0=1-(1-ti0).^(n-1);
p1=1-(1-tb0).^(n-1);
q0=(1-ti0).^n;
q1=(1-tb0).^n;
Pidl=q1./(1-q0+q1);
ti=b0./Pidl;
tb=b1./(1-Pidl);
ti1=0.5.*ti0+0.5.*ti;
tb1=0.5.*tb0+0.5.*tb;
tin=tin+ti1;
ti0=tin;
tbn=tbn+tb1;
tb0=tbn;
end
回答 (1 件)
Image Analyst
2016 年 8 月 20 日
0 投票
It looks like you are assigning some new values to them at the end of the loop. Now whether those are the right values, I don't know, since there are no comments in this code to explain what it's doing and therefore I didn't want to spend much time delving into it. So all I can suggest is that since you want to exit the while loop when both values equal one, you'll want to remove the equal signs from "while(ti0<=1&&tb0<=1)" otherwise when it reaches 1 it will still keep on doing the loop.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!