help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Obtention of state-space system equation for A,B,C,D matrixes including


From: Beginner1
Subject: Obtention of state-space system equation for A,B,C,D matrixes including discontinuities
Date: Tue, 20 Feb 2018 04:12:20 -0700 (MST)

Hi everyone!

I am trying to validate a small-signal model with state-space system
equations by using A,B,C and D matrixes. I'm wondering how to define the
A,B,C,D matrixes for the lsim command in the case they depend on
discontinuous variables. In my case, these matrixes depend on a function
called /enable/ which is discontinuous with time, so that it includes
non-linearities. My code is well structured since I obtain the response of
the system when A,B,C,D are constant.  However I don't know how to implement
the change when A,B,C,D depend on a function such that. 
Perhaps there is another way of obtaining the response of the system instead
of using the lsim command and maybe with another procedure it is possible to
include the dependency of A,B,C and D matrixes with the /enable/ function.
Any suggestion?

This is my code:
"%Packages call
  pkg control load
  pkg io load 
  
%State-space system parameters
  kv=15;
  Tv=0.05;
  kq=0.4;
  Tq=0.01;
  kdroop_AC=-3.3;
  droop_FSM=0.05;
  FSM_slope=droop_FSM/0.002;
  
%Definition of simulation time
  Tfinal = 3;
  t = (0:0.0001:Tfinal)';
  
%Enable function
  a = @(t) 0;
  b = @(t) 1;
  f = @(t,t0,t1) a(t) .* (t<t0) + b(t) .* (t>t0&t<t1) +a(t) .* (t>t1);
  t0=1; 
  t1=2;
  enable=f(t,t0,t1)
  
% Definition of A,B,C,D matrixes as a function of time
  for t=1:3
  A(t)=[0 0;0 0];
  B(t)=[-kv/Tv kv/Tv 0 0 0 0 -kv*FSM_slope*enable(t,t0,t1)/Tv
kv*enable(t,t0,t1)/Tv -kv*enable(t,t0,t1)/Tv;0 0 kq/Tq -kq/Tq
-(kq/Tq)*kdroop_AC (kq/Tq)*kdroop_AC 0 0 0];
  C(t)=[1 0;0 1];
  D(t)=[-kv kv 0 0 0 0 -kv*FSM_slope*enable(t,t0,t1) kv*enable(t,t0,t1)
-kv*enable(t,t0,t1);0 0 kq -kq -kq*kdroop_AC kq*kdroop_AC 0 0 0];
  endfor

% Definition of State-space equations 
% " x.=Ax+Bu; y=Cx+Du "
  stname = {'xv','xq'};
  sys = ss (A,B,C,D,'stname',stname);
%Input read
% Input read
  u_t=xlsread ('Outer_Loop1.xlsx', 'sheet1', 'A3:A300003');
  u_vdcref = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'B3:B300003');
  u_vdc = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'C3:C300003');
  u_qacref = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'D3:D300003');
  u_qac = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'E3:E300003');
  u_vacref = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'F3:F300003');
  u_vac = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'G3:G300003');
  u_fmeas = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'I3:I300003');
  u_pdcref = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'H3:H300003');
  u_paux = xlsread ('Outer_Loop1.xlsx', 'sheet1', 'L3:L300003');
%Initial conditions of state-space variables
x0=[0;0];
%Response of the model to perturbations 
 [y,t,x] = lsim(sys,U,t,x0);
"



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]