Matlab corresponding values between matrices?
Mostrar comentarios más antiguos
So i have these two matrices:
A =
745 780 800 860 810
780 780 760 695 815
744 825 720 690 750
715 860 700 670 620
B =
30 18 40 58 26
70 19 72 29 47
14 48 40 14 48
13 72 59 66 72
I want the user to enter a number N so the program will show how many of A's values are lower than the number the user typed. I did this with this command:
N=input('Type a number :')
C= nnz(A<N)
But now i want the program to show me the values of B that correspond to the A's values that are lower than the N number
(Sorry about my bad english, any ideas?)
Respuesta aceptada
Más respuestas (1)
Turlough Hughes
el 26 de En. de 2020
Editada: Turlough Hughes
el 27 de En. de 2020
This will show values of B that exist in A and which are also less than N.
result = B(ismember(B,A) & B<N)
If you need find the elements of B that exist in A within a certain tolerance there is also a function called ismembertol which will be appropriate in that case.
4 comentarios
Ilias Thanos
el 26 de En. de 2020
Editada: Ilias Thanos
el 26 de En. de 2020
Turlough Hughes
el 27 de En. de 2020
Well just looking at the data you provided, none of the values that are in B are in A that you provided above.
Ilias Thanos
el 27 de En. de 2020
Turlough Hughes
el 27 de En. de 2020
Ah ok, no worries. I see what you mean now.
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!