- The reading section will give you 'text_cell' as a cell array that contains all text data, each text line as a cell of the cell array.
- you can edit or update any cell value as like in section updating data.
- you can rewrite an updated file as like section writing updated text file.
- you can find your expected header text position by comparing '*' with each cell array text by using function strfind.
how to read text file and write same text file ?
104 views (last 30 days)
pruth on 15 Oct 2019
Hello matlab community. I have this text file with me which i need to read. I have some experince to read structured data from text file but this file is very new to me.
can somebody of you help me to read this file ? and more thing i need to do here is i need to write the same file after some processing. so my 2nd question is how to write the same text file with same headers and values we alredy read !
(ps: the values may change after processing but as for now lets say i need to write same values)
* upper layer boundaries above ground in km
* number of layers
* Sa read in?
* scaling parameter for Sa matrix
* real elevation angle for zenith direction
* Sa correlation length in km
* input filename
* surface albedo
* output directory path
* temperature pressure filename
* wavelength in nm
* altitude in km
* cross section folder
* heights for apriori profile filename
* vlidort config filename
* aerosol ext t, unisotropy g, omega w
* apriori profile filename
every sentence coming after * is a header.
Neeraj Kaberpanthi on 15 Oct 2019
You should try this code.
hope it will help you.
%% Reading text file
if text_line_read == -1
%% updating data
% lets change cell array index 2 which is 30.0 to 34.0
%% write updated text file