フィルターのクリア

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