Matlab problem. Command find
Mostra commenti meno recenti
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 Commento
Anusha Sridharan
il 27 Dic 2018
Modificato: Anusha Sridharan
il 2 Gen 2019
[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.
Risposte (1)
bsxfun(@lt,B,A)
5 Commenti
Przemek Tomaszewski
il 30 Ago 2018
"Only values are shown in the form 0 and 1. And how to make these values displayed in the form of valid values."
What are "valid values"?
Going back to your original question: "how to find the values of the B array, which are smaller than the value of the array A", you just need to do this:
idx = bsxfun(@lt,B,A);
B(idx)
that will give you all values that are less than some values of A. But I suspect that is not what you really want: you need to be more precise in your specification: what does "...smaller than the value of the array A" really mean? Smaller than all values of A? Smaller than the values of A in the same column? Is it acceptable if there are different numbers of values returned for each column?
Przemek Tomaszewski
il 30 Ago 2018
Przemek Tomaszewski
il 30 Ago 2018
Modificato: Przemek Tomaszewski
il 30 Ago 2018
"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.
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!