Indexing a sub-variable in Matlab base workspace
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ayobami Meadows
le 22 Nov 2021
Réponse apportée : Walter Roberson
le 22 Nov 2021
I do get following when trying to run the code. Error using min. Invalid data type. First argument must be numeric or logical. The concept is that I need to index the y(i).Cost as follow:
[y(i).Cost, y(i).Sol] = CostFunction(particles(i,:);
[ymin, index] = min(y);
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Nov 2021
[y(i).Cost, y(i).Sol] = CostFunction(particles(i,:);
[ymin, index] = min([y.Cost]);
0 commentaires
Plus de réponses (1)
KSSV
le 22 Nov 2021
This line:
[ymin, index] = min(y);
Your input to the function min is a structure. min takes an array as input. You need to change the input. Don't input a structure.
0 commentaires
Voir également
Catégories
En savoir plus sur Operators and Elementary Operations 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!