Azzera filtri
Azzera filtri

Continuing Matrix involving a function to make very large

1 visualizzazione (ultimi 30 giorni)
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 ];

Risposte (1)

Ameer Hamza
Ameer Hamza il 17 Giu 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);

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by