第一次可以请求到页面内容
这里我提供一种简单的脚本(不考虑键、角、二面角等复杂情况,只提供一种编程思路),请自行学习。
%---------------------------------------------------------------%
% ATOM SECTION %
%---------------------------------------------------------------%
Natoms = length(atom_data_molecule) ;
Bond_number = 0 ;
Angle_number = 0 ;
Dihedrals_number = 0 ;
Impropers_number = 0 ;
%---------------------------------------------------------------%
[fid,message] = fopen("box.data","wt");
%---------------------------------------------------------------%
% HEADER SECTION %
%---------------------------------------------------------------%
fprintf(fid,'%s\n',"LAMMPS data file making by MATLAB");
fprintf(fid,'\n');
fprintf(fid,'%d ',length(atom_data_molecule)); fprintf(fid,'%s\n ',"atoms");
% fprintf(fid,'%d ',length(new_bond)); fprintf(fid,'%s\n ',"bonds");
% fprintf(fid,'%d ',length(new_angle));fprintf(fid,'%s\n ',"angles");
% fprintf(fid,'%d ',length(new_atom)); fprintf(fid,'%s\n ',"atoms");
% fprintf(fid,'%d ',0); fprintf(fid,'%s\n ',"bonds");
% fprintf(fid,'%d ',0);fprintf(fid,'%s\n ',"angles");
fprintf(fid,'%s ',"0 ");fprintf(fid,'%s\n ',"dihedrals");
fprintf(fid,'%s ',"0 ");fprintf(fid,'%s\n ',"impropers");
%---------------------------------------------------------------%
fprintf(fid,'\n');
Natoms_type = 1;
Bonds_type = 0;
Angle_type = 0;
fprintf(fid,'%d ',Natoms_type); fprintf(fid,'%s\n ',"atom types");
fprintf(fid,'%d ',Bonds_type); fprintf(fid,'%s\n ',"bond types");
fprintf(fid,'%d ',Angle_type); fprintf(fid,'%s\n ',"angle types");
fprintf(fid,'%s ',"0 "); fprintf(fid,'%s\n ',"dihedral types");
fprintf(fid,'%s ',"0 "); fprintf(fid,'%s\n ',"improper types");
%---------------------------------------------------------------%
% COOR SECTION %
%---------------------------------------------------------------%
%fprintf(fid,'\n%s\n ',"PLEASE COPY THE ORGINAL BOX COORDINATION!");
%---------------------------------------------------------------%
% ATOM SECTION %
%---------------------------------------------------------------%
new_atom(:,1) = 1:lengthatom_data_molecule(:,5:7);
new_atom(:,2:4) = atom_data_molecule(:,5:7);
fprintf(fid,'\n');
fprintf(fid,'%s\n'," Atoms");
fprintf(fid,'\n');
[r,c]=size(new_atom);
for i=1:r
for j=1:c
fprintf(fid,'%s %s %s %s %s %s %s\n', num2str(new_atom(i,j)));
end
fprintf(fid,'\r');
end
- 您还可以看一下 张旭老师的【造物者】手把手带你做快递管理系统课程中的 【造物者】第二十七节·快递员的增加小节, 巩固相关知识点