필터 지우기
필터 지우기

Continuing Matrix involving a function to make very large

조회 수: 1 (최근 30일)
Seb apple
Seb apple 2020년 6월 17일
답변: Ameer Hamza 2020년 6월 17일
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 ];

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 6월 17일
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);

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by