필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Generating a matrix using other matrixes

조회 수: 1 (최근 30일)
alexaa1989
alexaa1989 2014년 8월 12일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi everyone I need to use 3 different permutation matrixes to make a new one here's how I have it so far
n=randi([1 10],1,1);
x1=[randperm(n)];
x2=[randperm(n)];
o=[randperm(n)];
cc=randsample(n,2);
c1=min(cc);
c2=max(cc);
so far as you know I have produced 3 matrixes with same dimension and 2 random number which indicate the places between arrays not arrays themself.
now I need to produce Y with same dimension using x1 x2 and o with these constraints applied on Y :
from c1+1 to c2 I need to have arrays from c1+1 to c2 using x1 (exact same permutation)
from c2 to end I need to have arrays from o which are not in Y so far(exact same permutation)
from 1 to c1 I need to have those arrays from x2 that are not used in Y so far(exact same permutation)
to be more clear Y =[ something from x2 , something from x1 , something from o ]
can anyone help me?
  댓글 수: 1
Michael Haderlein
Michael Haderlein 2014년 8월 12일
Come on, that's your 5th question on the basically same problem. You should start writing code by yourself. I didn't follow all of the previous answers, so it might be that I present now techniques which are inferior to answers already posted.
On your question, I think the solution is
Y=nan(size(x1));
Y(c1+1:c2)=x1(c1+1:c2);
temp_o=o(~ismember(o,Y));
Y(c2+1:end)=temp_o(end-length(Y)+c2+1:end);
temp_x2=x2(~ismember(x2,Y));
Y(1:c1)=temp_x2(1:c1);

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by