Are Simulink buses performance effective?

조회 수: 5 (최근 30일)
Marcus Jansson
Marcus Jansson 2017년 4월 26일
답변: Marcus Jansson 2017년 4월 27일
I have a Simulink program that uses structs, or buses as they are called in Simulink. The Simulink program contains a Matlab function and it's convenient to use structs in that function. The Simulink program uses several buses and some of them are inherited or propagated through in a hierarchy.
Are they any effective, performance-wise? Is it better to store a struct variable in a bus object and call the variable compared to create the variable within the Matlab code?

채택된 답변

Marcus Jansson
Marcus Jansson 2017년 4월 27일
When I asked the question I didn't know a way to investigate the performance of a Matlab function within a compiled Simulink program. Unfortunately Profiler cannot be used. Though, it was found that "tic toc" can be used.
Made a rough performance analysis, it seems that the structs/buses have some overhead. In my code it's for example 25% faster to call a subfunction that creates a 6x6 matrix from a 6x1 vector each timestep instead of creating it once the first timestep and store it in a bus and just retrieve it each timestep. Heavier operations like matrix inverse or backslash are though better to do once and store the result in a bus.
Consequently, do not rely on buses for optimum performance.

추가 답변 (1개)

KL
KL 2017년 4월 26일
Performance-wise I have never really observed any difference. For one thing, usage of structs/buses makes life easier and especially with simulink when you have too many signals, it makes the disgram look pretty neat and also easier when you use a single scope for multiple variables.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by