Matlab problem. Command find

조회 수: 6 (최근 30일)
Przemek Tomaszewski
Przemek Tomaszewski 2018년 8월 30일
편집: Anusha Sridharan 2019년 1월 2일
Hey. I have a problem. I have an array with dimensions A = 1 x 10 and an array B = 12015x10. My question is: how to find the values of the B array, which are smaller than the value of the array A. I tried to do it with the find command:
c = find(A<B)
but the following message is displayed: "Matrix dimensions must agree".
PS. Sorry for my language but still learning.
  댓글 수: 1
Anusha Sridharan
Anusha Sridharan 2018년 12월 27일
편집: Anusha Sridharan 2019년 1월 2일
[Answers Dev] Restored edits
Hey. I have a problem. I have an array with dimensions A = 1 x 10 and an array B = 12015x10. My question is: how to find the values of the B array, which are smaller than the value of the array A. I tried to do it with the find command:
c = find(A<B)
but the following message is displayed: "Matrix dimensions must agree".
PS. Sorry for my language but still learning.

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

답변 (1개)

Stephen23
Stephen23 2018년 8월 30일
편집: Stephen23 2018년 8월 30일
You probably need to use bsxfun:
bsxfun(@lt,B,A)
  댓글 수: 5
Przemek Tomaszewski
Przemek Tomaszewski 2018년 8월 30일
편집: Przemek Tomaszewski 2018년 8월 30일
I wrote this badly. Now I would like to have an array of C, I would like to find values that will compensate for this "1".
idx=bsxfun(@gt, B, A);
d=c(idx);
Only the values from column 1 are displayed. How to make it display from all columns (10)?
Stephen23
Stephen23 2018년 12월 29일
편집: Stephen23 2018년 12월 29일
"If I have an array 2x2 A = [2 3; 4 5]. This, if I would look for values greater than 3, would display such a table [0 0 1 1]. And what I mean is that the values are displayed to me [4 5]."
Your example (with a scalar B) is easy to achieve:
>> A = [2,3;4,5];
>> B = 3;
>> C = A(A>B)
C =
4
5
However this only works as long as B is a scalar, whereas in your original question you state that "B = 12015x10". and "A = 1x10". To deal with those non-scalar arrays you would need to answer the questions I asked you in my previous comment.
Consider these arrays:
>> A = [1,3,5]
A =
1 3 5
>> B = [0,2,4;9,7,5;6,6,6;3,2,1]
B =
0 2 4
9 7 5
6 6 6
3 2 1
Please show the expected output.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by