필터 지우기
필터 지우기

Writing matrix for 2D plane of atoms

조회 수: 2 (최근 30일)
SAZZAD HOSSAIN
SAZZAD HOSSAIN 2013년 6월 22일
Hello all
I have a row of 100 atoms and i am considering nearest neighbour interaction. What that means is that each atom has an interaction with itself (self interaction) of magnitude 2; and each atom interacts with its two nearest neighbour atoms from each side of magnitude 1. This 1D problem is represented in matrix as
2 1 0 0 0 0 ...
-1 2 1 0 0 0 ...
0 -1 2 1 0 0 ...
0 0 -1 2 1 0 ...
.............
.............
Now, my problem is that i dont know how to write this matrix when instead of a 1D problem, i have a 2D plane of atoms with the same nearest neighbour interaction condition. Can someone please help me ???
Thanks in advance.
Sazzad

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 6월 22일
a = [-1 2 1];
n = 100;
m = numel(a)-1;
out = full(spdiags(ones(n,1)*[-1 2 1],-m:m,n,n));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by