100 permutation

I have the following matrix
x =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
I would like to have 100 different permutation and in each I change randomly one variable of each row with others like this
1 7 13 4 5
then
11 5 4 19 2
and so on

댓글 수: 15

Jan
Jan 2011년 11월 9일
What have you tried so far and which specific problem occurred?
Image Analyst
Image Analyst 2011년 11월 9일
In your first example, which row was that? Was it row 1? If so, it looks like 2 numbers got changed, not 1. And the next row does not look like it's only one number different than row 2.
Niki
Niki 2011년 11월 9일
yes, I need the combination , it does not matter for me how many changes
Fangjun Jiang
Fangjun Jiang 2011년 11월 9일
Then you need to clarify your question. You said "change randomly one variable of each row", which does not match your example.
Image Analyst
Image Analyst 2011년 11월 9일
And I consider "x" the variable. The numbers in the rows of x are simply "numbers" or "elements of x" not variables in themselves. At least that's how I think of it. I still have no idea which row got changed (in ANY way at all) to form "11 5 4 19 2"
Niki
Niki 2011년 11월 9일
it does not matter, for example at first it can starts with all possible changes with the first row , for example
1 7 13 19 20
1 11 3 4 5
1 6 14 15 20
and ....
then start with second one
however it does not matter which row , just from the first until the end
Niki
Niki 2011년 11월 9일
You can take a look at this
http://www.mathworks.com/matlabcentral/answers/20551-combination
Daniel Shub
Daniel Shub 2011년 11월 9일
In the end are you going to want the solution to be able to extend to a much larger matrix. If this is a simplification, it would help to let us know in advance. Also, like IA, I have no idea what is changing and how in your example.
Dr. Seis
Dr. Seis 2011년 11월 9일
Your examples are confusing. Let's say the resulting combination is the general form:
A B C D E
What range of numbers can A, B, C, D, and E be?
At first I thought that:
A can equal 1, 6, 11, or 16
B can equal 2, 7, 12, or 17
C can equal 3, 8, 13, or 18
D can equal 4, 9, 14, or 19
E can equal 5, 10, 15, or 20
But after your first example, that logic breaks down.
Niki
Niki 2011년 11월 9일
yes
it should be the same dimension,
for example if you have 5 variable in each row
then the created row should be included of 5 variables from each row
Niki
Niki 2011년 11월 9일
please take a look at this ,
http://www.mathworks.com/matlabcentral/answers/20551-combination
I think andri is doing well, but I want to put a limitation for example just 100 permutation
and on the other hand, I want to perform it not only on one raw but also for others
Titus Edelhofer
Titus Edelhofer 2011년 11월 9일
Hi Mohammad,
a suggestion: for 6 hours now people try to answer your question (and fail) just because nobody get's from your question a clear impression about what you want to do exactly. Perhaps it's time to elaborate on what you have and what exactly you want to get together with a meaningful (!) example ...??
Titus
Niki
Niki 2011년 11월 9일
Dear Titus
it is really clear Let say we have a matrix
x =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
then I want to get 100 permutation by changing the variables of each row
like
1 2 3 4 5
1 7 8 9 10
1 12 13 14 15
1 17 18 19 20
6 2 3 4 5
6 7 8 9 10
6 12 13 14 15
6 17 18 19 20
11 2 3 4 5
11 7 8 9 10
11 12 13 14 15
11 17 18 19 20
16 2 3 4 5
16 7 8 9 10
16 12 13 14 15
16 17 18 19 20
but I want to put a limitation , for example only 100 or more or less
and also the matrix that I put as an example was included of 5 variables but I want to do that for a matrix with more or less dimention
Image Analyst
Image Analyst 2011년 11월 9일
It's getting clearer. The above seems clear but I'm not sure where [11 5 4 19 2] comes from in your first post. That is not in your list just now.
Sven
Sven 2011년 11월 10일
Mohommad, have I answered your question on the original thread?
http://www.mathworks.com/matlabcentral/answers/20551-combination
Just set solutionLimit = 100, and it seems to solve this exact same question.

댓글을 달려면 로그인하십시오.

답변 (1개)

Dr. Seis
Dr. Seis 2011년 11월 9일

0 개 추천

Stab in the dark:
sizeX = [4,5];
permlimit = 100;
X = reshape(1:prod(sizeX),fliplr(sizeX))';
Y = zeros([permlimit, sizeX(2)]);
for ii = 1 : permlimit
for jj = 1 : sizeX(2)
Y(ii,jj) = X(randi(sizeX(1)),jj);
end
end
disp(Y)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2011년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by