In a randomly generated matrix how to find the position(row and column) of an element by using its value?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
karthikeyan vishnumohan
le 27 Mai 2020
Commenté : karthikeyan vishnumohan
le 28 Mai 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 commentaires
Réponse acceptée
KSSV
le 27 Mai 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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!