Indexing a sub-variable in Matlab base workspace
4 ビュー (過去 30 日間)
古いコメントを表示
Ayobami Meadows
2021 年 11 月 22 日
回答済み: Walter Roberson
2021 年 11 月 22 日
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 件のコメント
採用された回答
Walter Roberson
2021 年 11 月 22 日
[y(i).Cost, y(i).Sol] = CostFunction(particles(i,:);
[ymin, index] = min([y.Cost]);
0 件のコメント
その他の回答 (1 件)
KSSV
2021 年 11 月 22 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!