How to create the upper diagonal block matrix in a specific form.
Mostrar comentarios más antiguos

c = input('c ');
g = input('g ');
syms Lambda_n
M = cell(c+1,1);
a_t = min([1:c+1;repmat(c-g+1,1,c+1)]);
for i = 1:c+1
v = zeros(1,c+2-i, 'sym');
v(1)= Lambda_n*i;
MCell = repmat({diag(v)}, 1, a_t(i));
M{i} = blkdiag(MCell{:});
end
B=blkdiag(M{:});
'c' will determine the size of blocks which I already explained to you that they will be in decreasing order. 'g' is basically used in a_t = ,min{j,c-g}. Here a_t determines how many time a block should be repeated. So upto c-g the order of block upper diagonal matrix will be (i+1,i) and from c-g+1 upto c+1 it will be (c-g+1,c-g+1).
This is for the main diagonal block matrix which is shown in the picture. Similarly I want to create the upper diagonal as shown by the red line in the picture. I have tried to creat it using kron function but it was just not what i wanted. Kindly help me with this.
10 comentarios
Rik
el 20 de Abr. de 2020
Each added part seems to be [zeros(k,1) A*eye(k)]. Is your question how to create the matrix in the image? It looks like you describe B as a matrix in your code, but it makes more sense that B is a scalar in your image. How would you define A?
raina RAJ
el 20 de Abr. de 2020
Rik
el 20 de Abr. de 2020
So A is actually not the same each time it is used? That seems a very strange thing to do.
Since you have managed to generate the appropriate B, what issues did you encounter when trying to write the code for A?
raina RAJ
el 20 de Abr. de 2020
Rik
el 20 de Abr. de 2020
That block will not be of size [2 3], but of size [2 3].*size(A). You should be able to use that to assign the contents to your pre-defined full array.
raina RAJ
el 20 de Abr. de 2020
Rik
el 20 de Abr. de 2020
You didn't explain how to create A. Since that is apparently obvious, the creation of that matrix shouldn't be a problem.
raina RAJ
el 20 de Abr. de 2020
raina RAJ
el 21 de Abr. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!