Mutual array between matrixes ( complete )

1 visualización (últimos 30 días)
alexaa1989
alexaa1989 el 11 de Ag. de 2014
Comentada: alexaa1989 el 15 de Ag. de 2014
Thank you all for your previous answers however it seems that I could not resolve the problem so I decided to explain it in more details hope someone can help
I have 3 matrixes: x1=[8,4,2, 1,7,3 ,5,6] x2=[4,3,5, 7,6,2 ,1,8] o=[8,1,3,5,2,6,4,7]
I generate two other matrixes as follow using x1 and x2 and o y1=[5,2,8, 1,7,3 ,6,4] y2=[8,1,3, 7,6,2 ,5,4]
here is how y1 and y2 are produced: for the middle section of y1 and y2 I used exactly the same part in x1 and x2 that are pointed with Bold after that for the parts in the right side of Bold I use parts of (o)that are not appeared in y1 and y2 so far
for the left side of Bold I use all arrays from x2 that are not still used in y1 and same for x1 and y2 I have coded some of it as follow
x1=[8,4,2,1,7,3,5,6]
x2=[4,3,5,7,6,2,1,8]
o=[8,1,3,5,2,6,4,7]
c1=3;
c2=6;
y1=[ V1 x1(c1+1:c2) V2 ]
y2=[ V3 x2(c1+1:c2) V4 ]
I need to define V1 V2 V3 V4
  3 comentarios
Joseph Cheng
Joseph Cheng el 11 de Ag. de 2014
Editada: Joseph Cheng el 11 de Ag. de 2014
in your direct message you wrote
v1 v2 v3 v4 are the codes to define what I have been wanting
of course if you can code the program in a different way I would be happy to use it
my comment is can you supply what they should be manually so i can better understand your conditions.
alexaa1989
alexaa1989 el 11 de Ag. de 2014
My apologies, I misundrestood.
V1=[8,4,2]
x1(c1+1:c2)=[1,7,3]
V2=[5,6]
V3=[4,3,5]
x2(c1+1:c2)=[7,6,2]
V4=[1,8]

Iniciar sesión para comentar.

Respuestas (2)

Christopher Berry
Christopher Berry el 14 de Ag. de 2014
I think that your algorithm description and examples values are contradictory, so its hard to answer this exactly. But, I will suggest you look at the function setdiff. This will let you find the elements of one set that are not present in another set. See the documentation below
  1 comentario
alexaa1989
alexaa1989 el 15 de Ag. de 2014
thank you for your response but I have written it successfully

Iniciar sesión para comentar.


Roger Stafford
Roger Stafford el 14 de Ag. de 2014
Christopher is right. The function you need is 'setdiff' using the 'stable' option.
n = length(x1);
y1 = x1((c1+1):c2);
v2 = setdiff(o,y1,'stable');
v2 = v2(end-n+c2+1:end);
y2 = x2((c1+1):c2);
v4 = setdiff(o,y2,'stable');
v4 = v4(end-n+c2+1:end);
v1 = setdiff(x2,[y1,v2],'stable');
v3 = setdiff(x1,[y2,v4],'stable');
y1 = [v1,y1,v2];
y2 = [v3,y2,v4];
As Christopher pointed out, you contradicted yourself in your comment, Alexaa1989. The v's there are different from those in the original problem statement. I have assumed that the original statement is the correct one.
  1 comentario
alexaa1989
alexaa1989 el 15 de Ag. de 2014
thank you for your response but I have written it successfully

Iniciar sesión para comentar.

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by