Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help needed with nested conditional running through nested loop

TastyPITastyPI Member Posts: 2
First off let me say thanks to anyone taking the time to look at this thread. It is my first time getting on a forum and i am not really sure how to start. Also i should say i am extremely new at matlab and programming in general.

My code:
num_rows=input('enter the number of rows: ');
for l=0:((2^(num_rows^2))-1);
tleft = de2bi(l,(num_rows^2),2,'left-msb');
A = vec2mat(tleft,num_rows)
for i=1:1:num_rows
for j=1:1:num_rows
for k=1:1:num_rows
if A(i,j)==1
if A(j,k)==1
if A(i,k)==1
disp 'true';
else
disp 'false';
end
else
disp 'true';
end
else
disp 'true';
end
end
end
end
end

What i want to do is if there is a false at all then just display one false. If a false does not occur then display one true. I Would advise running this code with input 2 to see what is going on, since input 3 will give you 512 matrices and so on and so forth.


Sign In or Register to comment.