How to update variable content for every iteration?
Show older comments
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
Answers (1)
Image Analyst
on 20 Aug 2016
0 votes
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.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!