Filter löschen
Filter löschen

Continuing Matrix involving a function to make very large

1 Ansicht (letzte 30 Tage)
Seb apple
Seb apple am 17 Jun. 2020
Beantwortet: Ameer Hamza am 17 Jun. 2020
Hi all, i have a typed square matrix and need to expand it to be very large how ever this will take far too long to do manually. my matrix code is below please help if you know any function to expend it while keeping the same pattern.
thanks in advance
syms e P n
c=1;
G(n)=e/(2*(P+0.5*(1i*n*c)-(0.25*(n)^2)));
j=[1 0 G(7) 0 0 0 0 0 0 0 0 0 0 0 0;0 1 0 G(6) 0 0 0 0 0 0 0 0 0 0 0; G(5) 0 1 0 G(5) 0 0 0 0 0 0 0 0 0 0; 0 G(4) 0 1 0 G(4) 0 0 0 0 0 0 0 0 0; 0 0 G(3) 0 1 0 G(3) 0 0 0 0 0 0 0 0; 0 0 0 G(2) 0 1 0 G(2) 0 0 0 0 0 0 0; 0 0 0 0 G(1) 0 1 0 G(1) 0 0 0 0 0 0 ; 0 0 0 0 0 G(0) 0 1 0 G(0) 0 0 0 0 0; 0 0 0 0 0 0 G(-1) 0 1 0 G(-1) 0 0 0 0; 0 0 0 0 0 0 0 G(-2) 0 1 0 G(-2) 0 0 0; 0 0 0 0 0 0 0 0 G(-3) 0 1 0 G(-3) 0 0; 0 0 0 0 0 0 0 0 0 G(-4) 0 1 0 G(-4) 0; 0 0 0 0 0 0 0 0 0 0 G(-5) 0 1 0 G(-5); 0 0 0 0 0 0 0 0 0 0 0 G(-6) 0 1 0; 0 0 0 0 0 0 0 0 0 0 0 0 G(-7) 0 1 ];

Antworten (1)

Ameer Hamza
Ameer Hamza am 17 Jun. 2020
Try this
syms e o n
c=1;
P = 1;
G(n)=e./(2.*(P+0.5*(1i*n.*c)-(0.25*(n)^2)));
N = 15;
l_start = 5;
u_start = 7;
l_end = l_start-N+3;
u_end = u_start-N+3;
j = diag(ones(1,N)) + diag(G(l_start:-1:l_end), -2) + diag(G(u_start:-1:u_end), 2);

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by