Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

how to use kron command to form a 2D matrix when 1D is known

1 vue (au cours des 30 derniers jours)
Jiali
Jiali le 15 Juin 2021
Clôturé : Jiali le 15 Juil 2021
Dear community,
I would like to use Kron command to form a 2D stencil grid when 1D matrix of row or column is known. For example, the below code is shown:
Nx=10;
Ny=8;
% every row or column in 1D should be in the below format
A=[-1*ones(Nx,1), ones(Nx,1)];
DeX=spdiags(A,[0 1],Nx,Nx);
DeX(Nx,Nx-1)=1;
B=[-1*ones(Ny,1),ones(Ny,1)];
DeY=spdiags(B,[0 1],Ny,Ny);
DeY(Ny,Ny-1)=1;
DeX_2D=kron(eye(Ny),DeX);
DeY_2D=kron(DeY,eye(Nx));
Is my understanding correct? Could you please lend me a hand?
Regards,
Jiali

Réponses (0)

Cette question est clôturée.

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by