필터 지우기
필터 지우기

Indexing a sub-variable in Matlab base workspace

조회 수: 2 (최근 30일)
Ayobami Meadows
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);

채택된 답변

Walter Roberson
Walter Roberson 2021년 11월 22일
[y(i).Cost, y(i).Sol] = CostFunction(particles(i,:);
[ymin, index] = min([y.Cost]);

추가 답변 (1개)

KSSV
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.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by