Simulation of SimuLink Block From Matlab Function (Errors)
Show older comments
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 Comment
Kaustubha Govind
on 27 Jun 2011
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.
Answers (2)
Fangjun Jiang
on 27 Jun 2011
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
on 28 Jun 2011
0 votes
1 Comment
Rajagopal N
on 6 Mar 2020
Edited: Rajagopal N
on 6 Mar 2020
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.
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!