extracting values from text files as matrix format
4 views (last 30 days)
I have a text file whose format as follows;
******** Week 887 almanac for PRN-01 ********
******** Week 887 almanac for PRN-02 ********
There are several ***** week ****** exist in the text file. I need to store each values (ID,Health, Eccentricity) as a matrix format. How can I store these values as a matrix or array format?
Azzi Abdelmalek on 27 Aug 2016
More Answers (1)
dpb on 27 Aug 2016
I'll presume you'll also want to know the week number...
>> fmt1='%*s Week %f';
>> d=; % empty array for the data
>> while ~feof(fid) % until reach EOF
d=[d; ... % read and concatenate into array
887.0000 1.0000 0 0.0058
888.0000 1.0000 0 0.0060
The in-place augmentation of the array isn't ideal from standpoint of efficiency but unless the file is quite large probably faster than the effort to scan the file and preallocate and it's certainly trivial to code...