i need to compare two arrays

조회 수: 3 (최근 30일)
Omar Almahallawy
Omar Almahallawy 2019년 3월 25일
답변: Steven Lord 2019년 3월 25일
hello, i have a matrix of size (3 x 4 ) and i need to compare each column with a seperate row respectively.
this may seem confusing but bare with me.
for example.
A= [21 50 60 70
60 70 80 90
27 51 38 35]
B= 19 51 60
C= 20 60 80
D= 80 70 40
E= 50 40 95
RESULT= 51 60 70 95
60 80 80 95
51 60 40 40
so i want to know how to compare the first column in A with row B and second column in A with row C and so on....
baring in mind that when comparing each element, i need the verry next number from rows B C D and E.
  댓글 수: 1
dpb
dpb 2019년 3월 25일
We're not so close to be "baring" all, methinks... :)
Clear as mud! :(
'Splain how you came up with the solution by the result of this "comparison"...

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2019년 3월 25일
So I think calling interp1 on each column using the 'next' method is what you're trying to do.
A= [21 50 60 70; ...
60 70 80 90; ...
27 51 38 35];
B = [19, 51, 60];
interp1(B, B, A(:, 1), 'next', 'extrap')

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by