Professional Documents
Culture Documents
Comp - Project 02 - 210400
Comp - Project 02 - 210400
Computational Project - 02
G.Kalyan
210400
% Use uigetfile to manually select the DSMC data file
[dsmc_filename, dsmc_path] = uigetfile('*.txt', 'Select DSMC Data
File');
if dsmc_filename == 0
error('No file selected.');
end
dsmc_data_file = fullfile(dsmc_path, dsmc_filename);
% Use uigetfile to manually select the MD data file
[md_filename, md_path] = uigetfile('*.txt', 'Select MD Data File');
if md_filename == 0
error('No file selected.');
end
md_data_file = fullfile(md_path, md_filename);
% Ignore header lines until reaching the line containing numeric data
while true
line = fgetl(fid_dsmc);
if ~ischar(line)
error('No numeric data found in the DSMC file.');
elseif startsWith(line, 'ITEM: ATOMS')
break; % Exit the loop when numeric data is reached
end
end
if exist(md_data_file, 'file') ~= 2
error('The MD file %s does not exist or is not accessible.',
md_data_file);
end
% Access the MD file for reading
fid_md = fopen(md_data_file, 'r');
% Ignore header lines until reaching the line containing numeric data
while true
line = fgetl(fid_md);
if ~ischar(line)
error('No numeric data found in the MD file.');
elseif startsWith(line, 'ITEM: ATOMS')
break;
% Terminate the loop upon reaching numeric data
end
end
% Parse numeric data using textscan
md_data = textscan(fid_md, '%f %f %f %f %f %f %f');
% Terminate access to the MD file
fclose(fid_md);
% Transform MD data from cell array to matrix format
md_data = cell2mat(md_data);
% Retrieve velocity components from MD dataset
Results obtained:
Graph Obtained: