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

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
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
Khalid Muhd 2011년 6월 28일

0 개 추천

Thanks guys,
I have found out the problem for this, there is a clash of variable used in my code and the simulink model, variable called 'round', I think this causes the problem.
I have change it to another name and it works fine.
Thanks guys for the reply.

댓글 수: 1

Rajagopal N
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에 대해 자세히 알아보기

질문:

2011년 6월 27일

편집:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by