MATLAB Answers

Using while loop in normalized matrix

14 views (last 30 days)
Kamil Dyga
Kamil Dyga on 22 Sep 2021 at 0:11
Commented: Kamil Dyga on 22 Sep 2021 at 15:22
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)

Accepted Answer

KSSV
KSSV on 22 Sep 2021 at 3:47
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 Comment
Kamil Dyga
Kamil Dyga on 22 Sep 2021 at 15:22
Thank you :)
Maybe you have some solution how can I search quicker needed value?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!