AmesimKnowledge

Advanced examples > Linear analysis

MATLAB

Copy

% Retrieve linearization times (if needed)
amela('scrdemo2')

% Run the simulation
amerunsingle('scrdemo2');

% select the index of the jacfile to use
jacfileIndex = 0

[A,B,C,D,x,u,y,t,xv]=ameloadj('scrdemo2',jacfileIndex);

w=2*pi*logspace(-1,2,400);

% uindex is the index of the control variable (Note that the indexes start at 1)
uindex = 1;
uname = deblank(u(uindex,:));

% yindex is the index of the observer variable (Note that the indexes start at 1)
yindex = 1;
yname = deblank(y(yindex,:));

% Compute bode using bode
[mag,phase] = bode(A,B(:,:,1),C,D(:,:,1),uindex,w);

% Creation of the Bode graph (Magnitude)
subplot(2,1,1);
loglog(w/(2*pi),mag);
xlabel('Frequency [rad/s]')
ylabel('Gain')
title([yname ' / ' uname]);
set(get(gca,'Title'),'FontSize',8)
grid on;

% Creation of the Bode graph (Phase)
subplot(2,1,2);
semilogx(w/(2*pi),phase);
xlabel('Frequency [rad/s]')
ylabel('Phase [deg]')
grid on;

Figure 26: Bode plot at t=0s

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Scripting/xid1133464 · retrieved 2026-07-17