Simulink Programmatic Modeling - Large quantity of blocks
조회 수: 4 (최근 30일)
이전 댓글 표시
Regards,
I have written a script to create a Simulink model via MATLAB lines of code systematically. Said script is scalable to increase the number of blocks to model a discretized physical problem with Simscape Multibody. The code works correctly and has been tested for small numbers of blocks. However, the amount of computational time to create the Simulink model is relatively high. Currently, I have a script that should make a Simulink model with a little over 2000 blocks. This script has been running for seven days now. MATLAB has not crashed or stopped, and according to the Windows task manager, it consumes 45GB of RAM and a moderate amount of processor resources.
At this point, I ask myself the following:
a) How to know if the model is still being created or just MATLAB has failed and should be stopped?
b) is there a limit to the number of blocks within a Simulink model?
I appreciate any helpful advice or information on what decision to make.
댓글 수: 0
답변 (1개)
Jonas
2021년 2월 10일
편집: Jonas
2021년 2월 10일
I have never programatically created a Simulink model, so I admire you for doing that, but cannot help with the specific functions you are calling to perform your task.
I suggest adding flags to your script to get feedback on the process of your script. You can use disp() to print to the Command Window during your loops, such as the index. You can also use sprintf() for example.
I don't know if there is a practical limit to the number of Simulink blocks, but 2000 is surely not too many. I am currently working on a model with a multitude of blocks.
If it is indeed so that MATLAB is struggling with creating many blocks, you may opt for creating smaller submodels, and then putting those submodels as a Model Reference in a larger model as a final step. This way, not all blocks are to be created in one large model.
You could also run your script for creating a smaller model, and run the Code Profiler. This way you can identify the sections of code which take long to execute and try to fix it. You do this by clicking this button in the editor:
Of course, it only displays the final report after the code has finished executing. So you should run it when your script is generating the small model and actually finishes. You could then run it again, when you increase the model a bit to see how your code scales with the size of the model you generate.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simscape Multibody에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!