MATLAB Answers

How to observe changing responses over time in simulink

2 views (last 30 days)
Tyler Mudge
Tyler Mudge on 12 Dec 2020
Commented: Mathieu NOE on 13 Dec 2020
Hello, i am trying to observe the change of position of a system with respect to time. The mass of the system changes at t=20s by 15%, and I can show this in Matlab, but my plot is coming from a simulink model including a PID controller and a Transfer Function. I have also been able to vary the transfer function with respect to time, which, I think should change the response of the system with respect to time, so my question is, how do I observe this change of the response with respect to time from Simulink.
%% Define knowns
g = 9.81; % gravity [m/s^2]
k = 1.32435*10^-4; % Magnet force constant, [N/amp]
x_0 = 0.015; % steady state position [m]
for t = 1:1:50
if t <20
i_0 = 1; % Steady state amps, assumed from NYU experiment [amp]
%% Define variable parameters
i = 1;
R = 10; % From NYU experiment [Ohm]
L = 0.4125; % Inductance from NYU experiment [Henry]
%% Checking Current System Stability
for t = 1:1:50
if t < 20
a(t) = (2*k*i_0)/(0.06*x_0^2); % num of TF
b(t) = (2*k*i_0^2)/(0.06*x_0^3); % part of den for TF
a(t) = (2*k*i_0)/(0.069*x_0^2); % num of TF
b(t) = (2*k*i_0^2)/(0.069*x_0^3); % part of den for TF
% a(t) = (2*k*i_0)/(m(t)*x_0^2); % num of TF
% b(t) = (2*k*i_0^2)/(m(t)*x_0^3); % part of den for TF
% num = [a];
% den = [1 0 b];
% sys = tf(num,den)
% % step(sys,t)
%% Simulate Model
maglev_sim = sim('Maglev_Model.slx');
%% Plotting m = 0.06 kg response
title('Position Response for m = 0.06kg')
ylabel('Position (m)')
xlabel('Time (s)')
  1 Comment
Mathieu NOE
Mathieu NOE on 13 Dec 2020
in your simulink file, you are using the standard transfer function bloc that works only with fixed coefficients
you have to change that to time varying bloc , as example :

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!