Can anyone check my code please?
조회 수: 1(최근 30일)
at first step i have two matrices A1,A2. There are some same value existed in both A1,A2. So i extracted their indexes in two vectors.
at second step : i have two vectors D1, D2 containing values relative to these extracted values from A1,A2.
i compared values of D1 and D2 in order to change position of extracted elements as following :
if D1(i)>D2(j), i will keep value in A2 and remove it from A1.
if D1(i)=<D2(j), i will keep value in A1 and remove it from A2.
based on indexes i used this code :
if D1(I11(i1))> D2(I22(i2))
elseif D1(I11(i1)) =< D2(I22(i2))
I111 : index of extracted value from A1.
I222 : index of extracted value from A2 .
I11 : index of relative value extracted from A1 in D1
I22 : index of relative value extracted from A2 in D2
I don't know what is wrong with my code, it doesn't work as i want.
could you please check with me?
thanks in advance
KALYAN ACHARJYA 2022년 10월 27일
편집: KALYAN ACHARJYA 2022년 10월 27일
Sufficints Hint: You can also do this in efficient way, I have shown work till D1 and D2, try the rest part yourself
A1=randi([1,10],[1,10]) % Just an Example
A2=randi([1,10],[1,10]) % Just an Example