### Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#">여기</a>"를 클릭하십시오.

## how to compare two arrays

### Omar Almahallawy (view profile)

on 1 May 2019
Latest activity Commented on by dpb

on 1 May 2019

### dpb (view profile)

A=[
9.9090 8.3211 9.5763
9.7926 8.2055 9.4335
9.3428 7.7533 8.8443]
COMPARED TO
B=[
7.9 9.5 9.5
8.7 10.3 10.3
9.5 11.1 11.1
10.3 11.9 11.9
11.1 12.7 12.7
11.9 14.3 14.3]
i need code that compares each row of A with each row of B
choosing the very next value from B for each element in A
elaboration:-
first element in A is 9.9090 comparing it to first row in B
7.9 is less so rejected
8.7 is less so rejected
9.5 is less so rejected
10.3 is more so acceped
result=
10.3 9.5 10.3
10.3 9.5 9.5
9.5 9.5 9.5

on 1 May 2019
Edited by dpb

### dpb (view profile)

on 1 May 2019

O=zeros(size(A));
for i=1:size(A,2)
O(:,i)=interp1(B(:,i),B(:,i),A(:,i),'next','extrap');
end

Omar Almahallawy

### Omar Almahallawy (view profile)

on 1 May 2019
is there a way i can have all the columns nex to each other other than iterations
O=
10.3
10.3
9.5
O=
9.5
9.5
9.5
O=
10.3
9.5
9.5
can i change it to be like this
O=
10.3 9.5 10.3
10.3 9.5 9.5
9.5 9.5 9.5
dpb

### dpb (view profile)

on 1 May 2019
Just store into array by column...see updated Answer. (Figured that obvious, sorry...)