这段代码在 Matlab 中给了我一个情节,但在 Octave 中没有

问题描述

代码运行良好,并在我在 Matlab 中运行时为我提供了绘图,但它在 Octave 中没有给我任何输出,请帮助。 (代码用于生成二维点阵,它应该输出一个图)

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,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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)