avoid Performance loss due to S-Function in Simulink
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i need for visualisation a scope in simulink which plots not only the actual value, so i change the sfunxy to autoscale and create a additional patch command to slove my problem this works so far but i gets while running slower and slower, the tester needs for the first 10s less then 4s for 10-20s its allready 1 minute and so on i think this is because the plot hold all the data how i can switch this of? i need only the actual data... here my code changes in sfunxy.mat in function mdlupdate
function sys=mdlUpdate(t,x,u,flag,ax,block,varargin)
% always return empty, there are no states...
%
sys = [];
%
% Locate the figure window associated with this block. If it's not a valid
% handle (it may have been closed by the user), then return.
%
FigHandle=GetSfunXYFigure(block);
if ~ishandle(FigHandle),
return
end
global traceData;
%
% Get UserData of the figure.
%
start=fix(u(2))-2;
if start<1
start=1;
end
ende=ceil(u(2))+2;
if ende>length(traceData.data)
ende= length(traceData.data);
end
ud = get(FigHandle,'UserData');
set(FigHandle,'NextPlot','replace');
set(ud.XYAxes, ...
'Visible','on',...
'Xlim', [u(1)-1 u(1)+1],...
'Ylim', [min(traceData.data(start:ende,6))-2, max(traceData.data(start:ende,7))-2],...
'XGrid', 'on',...
'YGrid','on');
set(ud.XYLine,...
'Xdata',u(1),...
'Ydata',u(2),...
'MarkerSize',20,...
'LineStyle','x',...
'EraseMode', 'background');
set(ud.XYTitle,'String','X Y Plot');
set(ud.XYAxes, 'NextPlot', 'add');
patch('Parent', ud.XYAxes,...
'XData',[traceData.data(start:ende,1);traceData.data(ende:-1:start,1)]',...
'YData',[traceData.data(start:ende,6);traceData.data(ende:-1:start,7)]',...
'FaceColor', [0, 1, 0], ...
'LineStyle','none',...
'FaceAlpha', 0.2);
set(FigHandle,'UserData',ud);
drawnow
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Model, Block, and Port Callbacks finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!