Any hint about this error?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Steps to reproduce (on Matlab R2013a 64bit Win machine):
R = rand(7,7);
>> ind_diag = eye(7);
>> R(ind_diag)
Error: Subscript indices must either be real positive integers or logicals.
>> ind_diag = ~~eye(7);
>> R(ind_diag)
ans =
0.8702
0.3818
0.6567
0.1098
0.4873
0.1401
0.7657
Cheers, Chris
1 commentaire
Réponse acceptée
Chris
le 16 Juil 2013
Plus de réponses (2)
harjeet singh
le 16 Juil 2013
use this
R = rand(7,7);
ind_diag = logical(eye(7));
R(ind_diag)
0 commentaires
harjeet singh
le 16 Juil 2013
eye() will give you a output in double format and when you use ~~eye() it automatically converts in logical.
the command R(ind_diag) uses inputs as logical so that's why you have to convert it into logical before use
Voir également
Catégories
En savoir plus sur Startup and Shutdown 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!