Matlab function to read data files having .Cmn extension
10 views (last 30 days)
Show older comments
Dr. Bapan Paul
on 23 Sep 2020
Edited: Dr. Bapan Paul
on 25 Sep 2020
I want to open and read data files in Matlab having extension '.Cmn'. Please inform me weather there is any Matlab function to open and read this type of data files. I could not attach a sample data file here as the file format is not supported.
I don't know much about CMN files. Some information is provided in the website 'FilExt' as "the CMN file type is primarily associated with Systems Management Server (SMS) by Microsoft Corporation.You need a suitable software like Systems Management Server (SMS) from Microsoft Corporation to open a CMN file."
The website recognizes the file as a 'text file' but I couldnot read the file in Matlab using the 'textscan' function. Also the 'online viewer' in the website reads the data file as:
chum, Kazakhstan
42.99850 74.75110 716.33210
MJdatet Time PRN Az Ele Lat Lon Stec Vtec S4
57372.372569 8.941667 1 319.78 11.39 50.417 64.330 37.91 12.65 -99.000
57372.372917 8.950000 1 319.74 11.58 50.350 64.431 37.85 12.68 -99.000
57372.373264 8.958333 1 319.70 11.77 50.284 64.529 37.69 12.68 -99.000
57372.373611 8.966667 1 319.66 11.96 50.218 64.626 37.53 12.68 -99.000
57372.373958 8.975000 1 319.62 12.15 50.153 64.722 37.42 12.70 -99.000
57372.374306 8.983333 1 319.58 12.34 50.088 64.816 37.20 12.68 -99.000
57372.374653 8.991667 1 319.54 12.52 50.025 64.908 37.00 12.67 -99.000
57372.375000 9.000000 1 319.50 12.71 49.961 64.999 36.84 12.67 -99.000
57372.375347 9.008333 1 319.45 12.90 49.899 65.088 36.57 12.63 -99.000
5 Comments
Walter Roberson
on 23 Sep 2020
readtable() has no problem reading the xlsx file, automatically skipping the first two lines.
Do you need the first two lines?
Accepted Answer
Ameer Hamza
on 23 Sep 2020
Edited: Ameer Hamza
on 23 Sep 2020
Try the following code. It ignores the first two lines of the file and starts from the line
MJdatet ...
The first row is used as column names for the table, and the rest is used as numeric data.
f = fopen('data.txt');
data = textscan(f, '%s%s%s%s%s%s%s%s%s%s', 'HeaderLines', 2);
data = [data{:}];
fclose(f);
column_names = data(1, :);
numeric_data = data(2:end,:);
numeric_data = cellfun(@(x) str2double(x), numeric_data);
T = array2table(numeric_data, 'VariableNames', column_names);
3 Comments
Ameer Hamza
on 24 Sep 2020
Yes, that would heve been a better solution.
Following will also work
readmatrix('data.txt', 'NumHeaderLines', 3)
More Answers (1)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!