Simulation of SimuLink Block From Matlab Function (Errors)
이전 댓글 표시
Hey guys,
I am trying to run a simulatin of a simulink block model from matlab function, but whenever i tried to call it out, it produce multiple error msgs:
Caused by: Error using ==> Winter_Code_v3 at 313 Error evaluating 'InitFcn' callback of Battery block (mask) 'Batt_Model_Pack/Battery1/Model/Continuous/Saturation Dynamic'. Error in 'Batt_Model_Pack/Battery1/Model/Continuous/Saturation Dynamic': Initialization commands cannot be evaluated. Error using ==> Winter_Code_v3 at 313 Error in 'Batt_Model_Pack/Battery1/Model/Continuous/Saturation Dynamic': Initialization commands cannot be evaluated. Error using ==> Winter_Code_v3 at 313 Error evaluating parameter '(sort(reshape(round(NumBitsAllowFinal), prod(size(NumBitsAllowFinal)),1)))' in 'Batt_Model_Pack/Battery1/Model/Continuous/Saturation Dynamic/Data Type Propagation': Index exceeds matrix dimensions.
The command that i use to call out : sim('Batt_Model_Pack', timestep*60);
i did run it before but in a smaller section code and it works fine but when integrating with other parts it produces this error.
Anyone has encounter this error before and care to share>
Thanks, really appreciate yr help.
댓글 수: 1
Kaustubha Govind
2011년 6월 27일
It seems there is an error evaluating the parameter of the block Batt_Model_Pack/Battery1/Model/Continuous/Saturation Dynamic. Perhaps one or more required variables have not been defined correctly in the workspace. Are all the variables used in the expression "(sort(reshape(round(NumBitsAllowFinal), prod(size(NumBitsAllowFinal)),1)))" defined in the base or model workspaces?
For easier debugging, I would recommend opening the model Batt_Model_Pack and attempt to run it directly (instead of from a MATLAB function). This will throw Simulink errors in a popup dialog that will highlight the blocks causing the error.
답변 (2개)
Fangjun Jiang
2011년 6월 27일
The error message says it all.
One of your blocks has a 'InitFcn' callback. The error happens when it tries to run that callback function. The particular line is
'(sort(reshape(round(NumBitsAllowFinal), prod(size(NumBitsAllowFinal)),1)))'
The error type is: Index exceeds matrix dimensions
Firs, try to load the model and run simulation manually without using the sim() command. Try to run the sort() command separately to see where is the error.
Khalid Muhd
2011년 6월 28일
0 개 추천
댓글 수: 1
Rajagopal N
2020년 3월 6일
편집: Rajagopal N
2020년 3월 6일
Thanks...
This was really helpful for me to solve the same issue which i have faced with the keyword 'size'.
I have used 'size' in my .m script which was a keyword in matlab.
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!