In a randomly generated matrix how to find the position(row and column) of an element by using its value?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
karthikeyan vishnumohan
el 27 de Mayo de 2020
Comentada: karthikeyan vishnumohan
el 28 de Mayo de 2020
Ive created a 5x5 matrix using the rand() function
A=rand(5)
0.4427 0.8173 0.8001 0.1455 0.1450
0.1067 0.8687 0.4314 0.1361 0.8530
0.9619 0.0844 0.9106 0.8693 0.6221
0.0046 0.3998 0.1818 0.5797 0.3510
0.7749 0.2599 0.2638 0.5499 0.5132
B=find(a==0.0844)
after i enter the above code for finding the position of that particular element, the output becomes " 0x1 empty double column vector "
Im literally a newbie to matlab software so kindly help me
0 comentarios
Respuesta aceptada
KSSV
el 27 de Mayo de 2020
Your matrix has floating point numbers..you cannot get the value you want using like that. You should use:
tol = 10^-5 ; % tolerance
B = find(abs(A-0.0844)<tol)
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!