Error:Brace indexing is not supported for variables of this type.

조회 수: 3 (최근 30일)
I am using the Responce optmization toolbox to optmize my controller and I am getting the following error:
=== Design Optimization (Elapsed: 0.253 sec) ===
Error:Brace indexing is not supported for variables of this type.
What I dont understand is the model will run for a while and succesful test different parameters. I can monitor the output and the convergres of the system. Then it will just throw the above error at some point. What is cauing this error. It would really help if it told me where this is occuring so I can track the error.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 7월 15일
I am not familiar with that tool, so I can only speak in generalities:
The kind of behaviour you describe can appear in cases where an output becomes empty when the code does not expect that as a possibility. There are cases where a cell array or table or string would be the expected outcome, but in which empty outcome is [] instead of empty cell or empty table or empty string. If the code then assumes that it can {} index the output than fails because [] is numeric and numeric cannot be {} indexed.
Such code needs an isempty() test added.
There are cases where algebraically the code should be fine, but because of floating point round-off, "The Law Of The Excluded Middle" fails to hold.
Nathaniel Goldfarb
Nathaniel Goldfarb 2021년 7월 30일
Right but how can I nail down exactly where the error is happening? The stack trace is terrible.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2021년 7월 30일
편집: Fangjun Jiang 2021년 7월 30일
Run "dbstop if error" in MATLAB Command Window first and then run your optimization. Hopefully you will be able to see the line of the source code when the error happens.
  댓글 수: 2
Nathaniel Goldfarb
Nathaniel Goldfarb 2021년 7월 30일
Do I just have to run "dbstop if error" window then hit the optmize button?
Should I close the Simulink model and/or the optmizizer first?
Fangjun Jiang
Fangjun Jiang 2021년 7월 30일
If the error pops up at the Simulink diagnostic window, you may not be able to see where in the source the error happened. But try it anyway.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by