How to check whether a condition is being met and move on to next if it dosent
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
chakradhar Reddy Vardhireddy
am 16 Okt. 2018
Kommentiert: chakradhar Reddy Vardhireddy
am 23 Okt. 2018
b=1.1; a=[1;5;6] c=a.*b; c=mean(c)
now I want to check if c lies between 6 and 7, if not i want to try b=1.2 and b=1.0 and b=1.3 and b=0.8 and so on decreasing and increasing
0 Kommentare
Akzeptierte Antwort
Viren Gupta
am 23 Okt. 2018
Since c is equal to the mean of b*1,b*5 and b*6, hence c = b*(1+5+6)/3 = 4*b. Therefore 6<4*b<7 implies b lies between 1.5 and 1.75 to satisfy your condition. One approach is to no longer decrease b as that won't give you the result. Start with b=1.1, use a do while loop with terminating condition as 6<c<7. in the body of the loop, compute c as you mentioned in the question.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!