Monday, April 28, 2008

Non-minimum phase systems and Bode plot

Consider the bode plot for the system shown below:

What can be said about this system:
  • The magnitude plot has a slope of -40 dB/decade. Its predominantly a second order system with double pole at origin.
  • It has a non-minimum phase characteristic with negative phase margin.
Now can we say that the system is BIBO unstable. One of my undergrad student pointed out this to me. He said that its an unstable system because it seemed to have a double pole at origin. Infact another student approximated this bode plot with following transfer function:

s = tf('s');

g = 507*(s+7)/(s^2*(s^2+601*s+600));

bode(g);


However, we need to keep following points in mind:
  • Non-minimum phase systems are not always unstable system.
  • Negative phase margin does not always imply instability.
  • For non-minimum phase systems with stable poles, we can't apply the approximations that hold for a standard second order system.

Sunday, April 13, 2008

Controllability and Condition Number

Consider following System (A, B) given as follows:

A =
-205.5237 198.3209 7.2028 0 -0.3256 0 0
198.3209 -205.5237 0 7.2028 0 0 0
0.0646 0 -0.0646 0 0 0 0
0 0.0646 0 -0.0646 0 0 0
0 0 0 0 0 0 0
463.7826 0 0 0 0 -43.4783 0
0 463.7826 0 0 0 0 -43.4783

B =

0
0
0
0
0.5600
0
0


Lets check the controllability of this system:

>> rank(ctrb(A,B)) = 4

You get a different result when you apply PBH (Popov-Belevitch-Hautus) test. In this test we check for the rank of [\lambda*I-A, B] matrix for each eigenvalue lambda. Following code (written by Gopal) performs the PBH test


% %%Controllabilaty test
Eigen_A=eig(A);
Data_Con = zeros(7,2);
for i=1:length(Eigen_A)
S=Eigen_A(i)*eye(length(A) );
D=S-A;
Control_A=[D B];%Formation of controllability matrix.
Rank_Con = rank(Control_A);
Data_Con(i,:)= [Eigen_A(i), Rank_Con];
end
Data_Con
%%%%%%%%%%%%%%%%%%
This gives

Data_Con =

-43.4783 6.0000
-43.4783 6.0000
-403.8457 7.0000
-7.2674 7.0000
0.0000 7.0000
-0.0634 7.0000
0 7.0000

where first column gives the eigen values and the second gives the corresponding rank.

As far as I know the controllability information obtained in either way should be equivalent. That means both methods should give same information about the controllability.

On little analysis I found that the matrix A is highly ill-conditioned with a condition number

>> cond(A) = 4.3373e+20

Could this be the reason for this anomoly. In other words, you can not rely on the controllability tests as it is ill-conditioned. Gopal tells me that this system pertains to a real system (related to a nuclear reactor) . In that case, how do you deal with such a system. Is there any process by which we can make it well-conditioned so that one can carry out computer simulations with good accuracy.

Monday, April 7, 2008

Stiff ODEs

Methods for solving differential equations may be divided into two classes namely explicit and implicit methods. Explicit methods calculate the state of a system at a later time from the state of the system at the current time, while an implicit method finds it by solving an equation involving both the current state of the system and the later one. Implicit methods require an extra computation and they can be much harder to implement. More information is available here. Implicit methods are used because many problems arising in real life are stiff for which the use of an explicit method requires impractically small time steps Δt to keep the error in the result bounded.

According to wikipedia, a stiff equation is a differential equation for which certain numerical methods for solving the equation are numerically unstable unless the step size is taken to be extremely small. The main idea is that the equation includes some terms that can lead to rapid variation in the solution.
We have seen that for solving ODE numerically the equation must be stable. This for example implies that the Jacobian of the RHS of the equation \dot{x} = f(x,t) must be a stable matrix. But with the Jacobian can be associated the Lipschitz constant, related with the norm of the Jacobian. Roughly a stiff problem is the combination of stability, with big eigenvalues (negative real part) of the Jacobian , implying a big norm, hence a big Lipschitz constant. This imply that the process described by the ODE contains components operating on different time scale.

For stiff problems, certain implicit methods give better accuracy than the explicit ones. For stiff problems, it is better to use Jacobian for solving the differential equations.

Thursday, April 3, 2008

Matlab's NN Toolbox

Following program demonstrates the use of a Feed-forward network in Matlab

%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Matlab Example 1
% Learning XOR function using a MLP

% Create a FFN

net = newff([0 1; 0 1], [2 1], {'logsig', 'logsig'},'traingd');

%Training patterns
P = [0 0 1 1; 0 1 0 1];
T = [0 1 1 0];

% Training parameters
net.trainParam.show = 100;
net.trainParam.lr = 0.8;
net.trainParam.epochs = 3000;
net.trainParam.goal = 1e5;

%Train the network
[net,tr] = train(net, P, T);

% Test the network
Y = sim(net, P)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Following program demonstrates the use of RBFN in matlab to learn a nonlinear function

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLAB EXAMPLE 2
% Radial Basis Function Network (RBFN)
clear all;

% Data set for training

x = [0:4:200];
yd = sqrt(x);
spread = 20;

% Create a RBF network

net = newrb(x, yd, 1e-5,20);

%test data
P = [0:0.01:200];
T = sqrt(P);
T1 = sim(net, P);

%mean square error

mse(T1-T)
figure(2)
plot(P,T,'r', P, T1, 'b--');
legend('Desired output', 'Actual Output');
xlabel('Input');
ylabel('Output');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 
pre { margin: 5px 20px; border: 1px dashed #666; padding: 5px; background: #f8f8f8; white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ }