发一个我修改过的m文件吧:
% MATLAB后处理 LAMMPS数据:求解管道流动,各量沿着管道半径方向的分布:
function [varargout] = scandump(varargin) % Function to scan LAMMPS dump file
clc;
clear all
try
dump = fopen('water_pos+vel.txt','r');
catch
error('Dumpfile not found!');
end
%定义初始的一些量:
R=30; %定义管道的半径
long=75; %管道的长度
h=input('请输入每一层的厚度:h='); %每一层的厚度
nlayer=floor(R/h+0.5); %沿着管道半径方向,所分的层数
i=1;
out.position(i,1) = 0;
fid = fopen('okokokokokokokok.txt','w'); % 把处理好的数据存储到density_ok.txt
fprintf(fid,'# r density/number ave_vel\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%% 读取并处理LAMMPS输出文件部分%%%%%%%%%%%%%%%%