Mutual array between matrixes ( complete )
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Joseph Cheng
2014년 8월 11일
편집: Joseph Cheng
2014년 8월 11일
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.
답변 (2개)
Christopher Berry
2014년 8월 14일
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
Roger Stafford
2014년 8월 14일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!