RPTRead(fname)

Versión 1.0.0.0 (2,59 KB) por Shugen Li
Read data from *.rpt file
239 Descargas
Actualizado 22 feb 2018

Ver licencia

function [d,t,dline,tline]=RPTRead(fname)
% FUNCTION:
% % Read data from *.rpt file which includes text and data
% % information.Content example is listed as following:
% % **********************************************************************
% % * NODE LOCATION REPORT *
% % **********************************************************************
% % Node Locations
% % Node ID Coord 1 Value Coord 2 Value Coord 3 Value Reference CID
% % 3 0.000000 0.000000 0.000000 (Global) Rectangular
% % 4 -0.621540 24.922939 -0.000000 (Global) Rectangular
% % .....
% % Node Locations
% % Node ID Analysis CID
% % 3 (Global) Rectangular
% % 4 (Global) Rectangular
% % .....
% INPUT:
% fname--File name
% OUTPUT:
% d:nX4 sized data array:
% 1st col stores node id;
% 2nd col stores x coordination;
% 3rd col stores y coordination;
% 4th col stores z coordination;
% t:Text cell array which stores header information and comment
% information line by line;
% dline: records data line number of the file;
% tline: records line number of text array.
% USEAGE:
% [d,t,dline,tline]=RPTRead('x0.rpt')
% Author: Li Haixing; Email:windchaser_lhx@163.com
% check number and type of arguments
if nargin < 1
error('Function requires one input argument');
elseif ~ischar(fname)
error('Input argument must be a string representing a filename');
end
% Open file
fid = fopen(fname);
if fid==-1
error('File not found or permission denied.');
end
%

%Initialize data array, text array, dline and tline
d = [];
t = { };
dline=0;
tline=0;
%

% Process
while ~feof(fid)
s=fgets(fid);
[data, ncols, errmsg, nxtindex]= sscanf(s, '%f');
if ~isempty(data)
dline = dline+1;
eval(['d','(:,',num2str(dline),')','=data']);
sx = fgets(fid);
[data2, ncols, errmsg, nxtindex]= sscanf(sx, '%f');
if ~isempty(data2)
off=-1*length(sx);
fseek(fid,off,'cof');
else
while ~feof(fid)
s=fgets(fid);
tline=tline+1;
eval(['t','{',num2str(tline),'}','=s']);
end
break;
end
else
tline=tline+1;
eval(['t','{',num2str(tline),'}','=s']);
end
end

d=d';
t=t';
fclose(fid);
end

Citar como

Shugen Li (2026). RPTRead(fname) (https://es.mathworks.com/matlabcentral/fileexchange/66163-rptread-fname), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2007b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Data Import and Export en Help Center y MATLAB Answers.
Etiquetas Añadir etiquetas
Agradecimientos

Inspirado por: mhdrload.m

Versión Publicado Notas de la versión
1.0.0.0