I want to create a for loop which creates different pairs each time.

1 view (last 30 days)
ME
ME on 5 Mar 2015
Commented: ME on 5 Mar 2015
for i=1:p
for j=1:p
i~=j
disp('i is equal to');
disp(i);
disp('j is equal to');
disp(j);
end
end
I have made this however some pairs are the same e.g i= 1 j = 1 and so on
  3 Comments

Sign in to comment.

Accepted Answer

Chandrasekhar
Chandrasekhar on 5 Mar 2015
Edited: Chandrasekhar on 5 Mar 2015
for i=1:p
for j=1:p
if (i~=j)
disp('i is equal to');
disp(i);
disp('j is equal to');
disp(j);
end
end
end

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!