Hello,
How I should use 'while' loop to solve this problem?
I would like stop the program, when it will be x=1 and y=1 at the same moment?
a = 0.2;
b = 0.3;
c = rand
d = rand
m = [a c; b d];
d=normc(m);
x = d(1,1)+d(2,1)
y = d(1,2)+d(2,2)

 Akzeptierte Antwort

KSSV
KSSV am 22 Sep. 2021

1 Stimme

x = 0 ; y = 0 ;
a = 0.2;
b = 0.3;
while ~(x == 1 && y == 1)
c = rand ;
d = rand ;
m = [a c; b d];
d=normc(m);
x = d(1,1)+d(2,1)
y = d(1,2)+d(2,2)
end

1 Kommentar

Kamil Dyga
Kamil Dyga am 22 Sep. 2021
Thank you :)
Maybe you have some solution how can I search quicker needed value?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 22 Sep. 2021

Kommentiert:

am 22 Sep. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by