代码工作正常,当我在 Matlab 中运行它时给了我绘图,但它在 Octave 中没有给我任何输出,请帮忙。(代码用于生成 2D 晶格,它应该输出一个图)
function generate_2dlattice_p4mm()
n1=[-2:1:2];
n2=[-2:1:2];
n3=[-2:1:2];
V=[2 0 0; 0 2 0; 0 0 0];
basis=getbasis();
[nb]=size(basis);
atom = 1;
for k= 1:length(n1)
for l=1:length(n2)
for m=1:length(n3)
for b=1:nb
H= V(1,:)*n1(k) + V(2,:)*n2(l) + ...
V(3,:)*n3(m) + basis(b,1)*V(1,:) + basis(b,2)*V(2,:) + basis(b,3)*V(3,:);
X(atom) = H(1);
Y(atom) = H(2);
Z(atom) = H(3);
atom = atom + 1;
end
end
end
end
plot3(X,Y,Z,'o','MarkerFaceColor','r','MarkerSize',20);
end
function [b]=getbasis()
bg1=[0.2 0.3 0; 1-0.2 1-0.3 0; 1-0.3 0.2 0;0.3 1-0.2 0;...
1-0.2 0.3 0; 0.2 1-0.3 0; 0.3 0.2 0; 1-0.3 1-0.2 0];
bg2=[0.1 0.3 0; 1-0.1 1-0.3 0; 1-0.3 0.1 0; 0.3 1-0.1 0;...
1-0.1 0.3 0; 0.1 1-0.3 0; 0.3 0.1 0; 1-0.3 1-0.1 0];
be=[0.3 0.5 0; 1-0.3 0.5 0; 0.5 0.3 0; 0.5 1-0.3 0]
bc=[0.5 0 0; 0 0.5 0]
ba=[0 0 0];
b=[bg1;bg2;be;bc;ba];
end