Jordan Block is a square matrix with a scalar r on the main
Jordan Block is a square matrix with a scalar r on the main diagonal and 1’s on the diagonal right above it. All other entries are zero.
Write a MATLAB
function J=jordan(n,r)
which produces an nxn Jordan matrix with a scalar r on the main diagonal.
The function could use a single for loop for constructing matrix J.
Solution
Here is the matlab function j , program :
function [Vertex Details] = hullJordExp(A,t1,t2)
syms t;
isReal = isreal(eig(A));
n=size(A,1);
if (isReal)
[jordanBasis jordanBlock] = jordan(A);
symbolicExpo = simple(expm(jordanBlock*t));
else
symbolicExpo = simple(expm(A*t));
end
% k is an index used to enumerate the number of non-zero function inside
% symbolicExpo.
k=0;
for i=1:n
for j=1:n
if (symbolicExpo(i,j)~=0)
% When k==0 no value has been registered to the `Details`
% structure. In this case the function is registered and the
% matrix S has only one 1 and all other entries are set to 0.
if (k==0)
k=k+1;
Details{k}.fun=symbolicExpo(i,j);
S = zeros(n,n);
S(i,j)=1;
Details{k}.S=S;
end
% Have we already registered this function in `Details` ?
% Search throughout the entries of Details:
if (k>0)
isRegistered=0;
for p=1:k
if (symbolicExpo(i,j)==Details{p}.fun) %found already registered!
isRegistered=1;
S = Details{p}.S;
S(i,j)=1;
Details{p}.S=S;
end
end
% In the following case no function was found in `Details`
% matching the candidate one, so it is registered.
if (~isRegistered)
k=k+1;
Details{k}.fun=symbolicExpo(i,j);
S = zeros(n,n);
S(i,j)=1;
Details{k}.S=S;
end
end
end
end
end
% Now the minimum and maximum values of Details{*}.fun are calculated and
% are stored in Details as .minFun and .maxFun. For this purpose the
% function exhaustiveSearch is used.
for i=1:k
[m M]=exhaustiveSearch(Details{i}.fun,t1,t2,50);
Details{i}.minFun=m;
Details{i}.maxFun=M;
end
% Form the cartesian product space of min and max...
for i=1:k
X{i}={Details{i}.minFun,Details{i}.maxFun};
end
PROD = cartprod(X);
nProd = size(PROD,2);
for q=1:nProd
vertice = zeros(n,n);
for i=1:k
tmp = PROD{q}(i);
vertice = vertice + tmp{1}*Details{i}.S;
end
if (isReal)
Vertex{q}=jordanBasis*vertice/jordanBasis;
else
Vertex{q}=vertice;
end
end
Hope this helps!!

