How can I use a txt file as input of a table?

Hi, I have the attached .txt file and I want to use it as input in MATLAB. I want to create a 10x5 table using Time, Az, El, Range and Footp as variables.

Antworten (1)

Cedric
Cedric am 29 Okt. 2013
Bearbeitet: Cedric am 29 Okt. 2013

0 Stimmen

It is not trivial because there is a header and the decimal delimiter is the comma. If you need a numeric time stamp (suited for plotting) and numeric data, you can do it as follows:
% - Read data, replace comma with point as decimal sep., scan columns.
raw = fileread( 'SAT.txt' ) ;
raw = strrep( raw, ',', '.' ) ;
data = textscan( raw, '%s %s %f %f %f %f', 'HeaderLines', 4 ) ;
% - Aggregate to string time stamp and convert to numeric.
timeStamp_str = arrayfun(@(r) [data{1}{r}, ' ', data{2}{r}], ...
1:numel(data{1}), 'UniformOutput', false ) ;
timeStamp_num = datenum( timeStamp_str ) ;
% - Aggregate data into num array.
data = [data{3:end}] ;
Note that you can use timeStamp_str as labels for plot axes.

Diese Frage ist geschlossen.

Gefragt:

am 29 Okt. 2013

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by