variable length vectors crashing simulation

조회 수: 1 (최근 30일)
Vincenz Frenzel
Vincenz Frenzel 2018년 12월 19일
답변: Vincenz Frenzel 2018년 12월 19일
Hi,
I have developed a rather large simulink model with simulink functions and also some matlab functions. In an previous approach I had to use some variable length vectors which I defined as such, however I was able to get rid of all of them. Occasionally (in seemingly random cases) I get an error that I can not track down further and do not understand where it appears and originates and under what circumstances.
It reads: "An error occurred while running the simulation and the simulation was terminated
Caused by:
If X is a variable-length vector, it must not have length 1: scalar X must be fixed-size.
Component:Simulink | Category:Block error -Open-"
If I click on open, nothing happens unfortunately.
I would greatly appreciate any help to locate this tiny bug that crashes the entire simulation or approaches on how this could be located eg with the debugger. I had no luck with that.
Thanks,
Vincenz

채택된 답변

Vincenz Frenzel
Vincenz Frenzel 2018년 12월 19일
After another day of working with simulink I found the error. It was the command
h = hist(vector,unique(vector));
to find out which value in vector appears how often. Therefore h is variable in size. If all entries are the same though, h is length 1 which is obviously not acceptable.
Poor error reporting by MathWorks!
If this helped anyone, letr me know
Vincenz

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by