Unable to change InitialPopulationMatrix in GA problem options

I have a problem called fopt; in fopt.options, fopt.options.InitialPopulationMatrix = [];
fopt.options.InitialPopulationMatrix = 'doubleVector'; and finally, fopt.options.PopulationSize = 340 and
fopt.nvars = 11. So, I have a script where I define a variable w of size 340x11 and then set:
fopt.options.InitialPopulationMatrix = w
Matlab replies with
Invalid value for OPTIONS parameter InitialPopulationMatrix: must be a two-dimensional matrix.
I've tried everything I can to find the proble, but to no avail. Even setting the line just before
fopt.options.InitialPopulationMatrix = w
to
size(w)
returns
ans =
340 11
and ismatrix(w) returns 1..... I've never had any issues setting this property before, so any help greatly appreciated.

댓글 수: 2

Tom - how is w initialized? Could it be a cell array which would return the same above answers (for size and ismatrix)?
Tom Brenner
Tom Brenner 2019년 2월 1일
편집: Tom Brenner 2019년 2월 1일
Thank you for the reply. Aha! I found the trouble thanks to you! It was not a cell array, but rather was defined from reading numeric values from variables of class SINGLE. Simply changing w into class DOUBLE (w = double(.....).....) solved the issue!
Thank you sir!
Edit: seeing as you posted a comment rather than an answer, I cannot accept it as one.... But obviously you solved my issue.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2019년 2월 1일

편집:

2019년 2월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by