Creating a J*J Diagonal Matrix with Jth Diagonal element is also a matrixHello,
I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) where Aj is also a matrix which is defined as (a11,a12,a13;a21,a22,a23;a31,a32,a33). How can I define Aj as a variable in the m file then create the diagnoal matrix through Aj?
Could someone help on this please? Many Thanks in Advance!
"Jie " <jz286@cam.ac.uk> wrote in message <h6selu$9ng$1@fred.mathworks.com>...
> Hello,
>
> I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) w...
Create a block diagonal matrix from vectorsHi,
I'm a relatively new user in MATLAB and I'd appreciate if anyone can help me out with an answer or a reference on how to create block diagonal matrices from several vectors.
As an example, if I have the following 4 vectors,
d11=[1 5 9 13];
d12=[2 6 10 14];
d21=[3 7 11 15];
d22=[4 8 12 16];
what's the best way to create matrix D such that:
D=
1 2 0 0 0 0 0 0
3 4 0 0 0 0 0 0
0 0 5 6 0 0 0 0
0 0 7 8 0 0 0 0
0 0 0 0 9 10 0 0
0 0 0 0 11 12 0 0
0 0...
Creating a sparse block diagonal matrixHi,
does anyone know how to create what I think is called a sparse block diagonal matrix?
Here is an example:
I have one matrix that is sparse e.g. [1 0 0 0 ; 0 0 1 0 ; 0 0 1 0 ; 0 0 0 1 ] and want to create a new matrix where this matrix is repeted e.g. 10 times in the diagonal of a larger matrix i.e. a 40 x 40 matrix.
How can I do this in a the most sparse and efficieant way?
"Markus Nordberg" wrote in message <n7qmd3$3bc$1@newscl01ah.mathworks.com>...
> Hi,
> does anyone know how to create what I think is called a sparse block diagonal matrix?
> ...
Block diagonal matrix from a skew-symmetric matrixDear Group members,
I'm trying to solve the following algebra problem
Consider a skew-symmetric matrix of the form:
B=[0,A;
-At,0]
where 0 stands for a null matrix and At the transpose of matrix A.
Is it possible to obtain a transformation of this matrix such as the
new matrix in the new coordinates would be a block diagonal matrix of
the form:
C=[C1,0;
0,C2]
with C=Tt * B * T, being T the transformation matrix?
If possible how can I obtain such a transformation matrix?
Thanks,
RV
...
affecting a matrix rows as diagonal blocks in another matrixHi
Suppose i have a matrix A= [1 4 5
8 7 3
6 5 2]
I want to have a matrix B such each row of it has a row from A at the diagonal
B=[1 4 5 0 0 0 0 0 0
0 0 0 8 7 3 0 0 0
0 0 0 0 0 0 6 5 2]
how can i do it. I could do it with blkdiag but it supposes i input each row for the matrix, however i need something general since i need it for bigger matrices
Thanks
"matlab " <keep_smiling2100@yahoo.fr> wrote in message <jtkrgk$js0$1@newscl01ah.mathworks.com>...
> Hi
> Su...
block diagonal matrixHi all,
Does anybody know what is the most efficient way to cobstruct a diagonal matrix from a vector of entries?
For example I want to create:
1 0 0
0 2 0
0 0 3
from: a=1:3;
"blkdiag" does not work here since I need to enter the vector elements one by one which I can't since "a" can be very large.
Thanks,
Elnaz
On 9/5/2013 3:16 PM, Elnaz wrote:
> Hi all,
>
> Does anybody know what is the most efficient way to cobstruct a diagonal
?matrix from a vector of entries?
> For example I want to create:
> 1 0 ...
creating a matrix from diagonalsThis is quite a tricky for me.
I need to construct a matrix A(a,b) where a>b.
It will have a-b+1 number of diagonals containing b elements each.
Where ith diagonal starting from (i,1) and ending (b+i-1,b)
I have these diagonals with me. How do i construct this matrix A?
I do not want to use spdiags(). I tried it and find it too expensive.
mohitt wrote:
>
>
> This is quite a tricky for me.
> I need to construct a matrix A(a,b) where a>b.
> It will have a-b+1 number of diagonals containing b elements each.
> Where ith diagonal starting from (i,1) and ending (b+i-1,b)
&...
creating diagonal matrixHi,
Let say I have a vector B=[1 0] and I want to use this vector B repeating in this matrix A having size [8x16].
First, I initialize the matrix A with all zeros then I want to have the outcome as below:
A=
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0];
How can I use that vector B repeat several times on matrix A using some code? It looks like an ...
Is a matrix block diagonal?Hello,
How would you find whether a given symmetric matrix is block
diagonalizable (under shuffling of the indices)?
My matrix is very large, binary and symmetric. It is not sparse, it
has ~ 10% 1s. I want to find whether some indices cluster with
others, or whether the whole thing is irreducible.
Thanks,
Pedro
Pedro Bordalo wrote:
>
>
> Hello,
>
> How would you find whether a given symmetric matrix is block
> diagonalizable (under shuffling of the indices)?
>
> My matrix is very large, binary and symmetric. It is not sparse,
> it
> has ~ 10% 1s. I want to fi...
Block diagonal matrix constructionSuppose you have block A, B, C, ... How do you create a block diagonal
matrix with blocks A, B, C, ... on the diagonal? Without looping through the
elements of course.
/ Any ideas are much appreciated (google didn't help me)
john wrote:
> Suppose you have block A, B, C, ... How do you create a block diagonal
> matrix with blocks A, B, C, ... on the diagonal? Without looping
> through the elements of course.
>
> / Any ideas are much appreciated (google didn't help me)
Does HELP BLKDIAG do what you want?
--
Steve Lord
slord@mathworks.com
> &g...
To construct a block diagonal matrixI have two qubit density operator which have an n term approaching to infinity. I want to construct density matrix from it. which is a block dioganal matrix.I have some problem to do so.. Any help?
On 4/3/2013 3:11 AM, Niaz khan wrote:
> I have two qubit density operator which have an n term approaching to
> infinity. I want to construct density matrix from it. which is a block
> dioganal matrix.I have some problem to do so.. Any help?
>> lookfor diagonal
blkdiag - Block diagonal concatenation of matrix input arguments.
diag - Diagonal matrices and diagonals of...
creating a diagonal matrix with boundaries...Dear all,
I am no big Matlab expert and for some hours now, I have been struggling
with this "simple" program. However, I can't figure it out...
clear all
N=5;
boundary = 1;
diag_coeff=[1 -1];
position=[-1];
values=[];
for number=1:size(diag_coeff,2)
values(:,number) = ones(N,1).*diag_coeff(1,number);
placement(1,number) = (position -1 + number);
end
if boundary == 1; % if ok, create boundary
values(:,number+1)=ones(N,1).*diag_coeff(1,number); % left of diagonal
placement(1,number+1) = (-N+(size(diag_coeff,2))-1); % left of diagonal
values(:,number+...
construct diagonal block matrixI want to build a diagonal matrix such as
1 2 0 0 0 0
0 0 3 4 0 0
0 0 0 0 5 6
with a given (arbitrary) matrix,
1 2
3 4
5 6
without using loops and cell arrays (conversion takes time) blkdiag works with only parameters (a,b,c,d...) a,b,c,d... are row vectors.
suggestions?
Tim
Hi Tim,
I have a solution. Let
M = [1 2; 3 4; 5 6];
Then, the matrix you are looking for can be computed with the following two lines:
A = [diag(M(:,1)) diag(M(:,2))];
B = A(:,reshape(reshape(1:6,3,2)',1,6))
Hope this helps,
Danny
"Tim Yang" <dlISCool@gmail.com> wrote in message <h0u...
Block matrix: off Diagonal MatricesPlease Steve, you didn't tell how I can get the off diagonal
matrices? The 2D laplacian matrix has off diagonal matrices of
(alpha)I where I is identity matrix of the same dimension as the
diagonal matrix.
final matix: A = |B1 (a1)I ........ ... |
|(a2) B2 (a2)I ........ |
|....(a3)I B2 (a3)I ...|
|.... ... ... |
| (an)I Bn |
Your help will be much appreciated!
cheers
E4Home wrote:
> Please Steve, you didn't tell how I can get the off diagonal
> matrices? The 2D laplacian matrix has off diagonal matrices of
&g...