필터 지우기
필터 지우기

Plots via s-function

조회 수: 2 (최근 30일)
Tobias Gemaßmer
Tobias Gemaßmer 2011년 11월 24일
Hello,
I've written a Level2 S-Function, that plots space vector diagramms during my Simulink simulations. This is working so far, but the problem is that the execution time of the s-function slows down my simulation due to the matlab interpreter.
So my question is, is there any way to create and modify matlab-figures with a mex S-Function? After a lot of searching, I could not find any commands for doing that.
Thank you for your help
Tobias Gemaßmer

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 11월 24일
Hi Tobias,
hmm, then there is indeed not much more that can be done ... writing the S-function in C will not make much of a difference in this case I guess. You might profile your S-function (just call
profile on
before running the simulation and
profile report
afterwards. The report should show up the time spent in your S-Function. I don't expect much interesting there, but just to be sure ...
Titus

추가 답변 (3개)

Titus Edelhofer
Titus Edelhofer 2011년 11월 24일
Hi Tobias,
not really. What I would suggest is to reduce the sample time of the output so that the S-function (plotting) is not done every time step but e.g. every 10th step only ...
Second: how does the plotting work, do you redraw the entire plot every time step (plot(x,y)), or (preferably) do you store the handle of the plot in some work vector and do only update the line, something like
set(h, 'xdata', newXData, 'ydata', newYData);
This is usually significantly faster.
Titus

Tobias Gemaßmer
Tobias Gemaßmer 2011년 11월 24일
Hi Titus
thank you for your answer.
Since the plot is a space-vector-diagram, it consits of a couple of lines. I store the handle of every line in a work vector and update the x and y data. I already reduced the sample time of the S-function, which speeded up the simulation, but for me was kind of dissatisfactory.

Tobias Gemaßmer
Tobias Gemaßmer 2011년 11월 25일
Hi Titus,
By using the profiler, I recognized, that most of the calculation time is needed on some function according to the legend. So I was able to speed up the update function of my figure by having a static legend using
% Static legend
set(gca,'LegendColorbarListeners',[]);
setappdata(gca,'LegendColorbarManualSpace',1);
setappdata(gca,'LegendColorbarReclaimSpace',1);
So anyway, my function doesn't slow down the simulation any more. Thank you for your good advice
Tobias
  댓글 수: 1
Titus Edelhofer
Titus Edelhofer 2011년 11월 25일
Good to hear, so I guess the question might be seen as answered ...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by