gain information from a .cnv file

10 views (last 30 days)
I have some data stored in a .cnv file, the data is stored as follows:
# <!-- Pressure voltage, Pressure, Strain Gauge -->
# name 0 = prSM: Pressure, Strain Gauge [db]
# name 1 = sal00: Salinity, Practical [PSU]
# name 2 = t090C: Temperature [ITS-90, deg C]
# datcnv_skipover = 0
# file_type = ascii
-0.051 0.0312 15.4328
-0.061 0.0512 15.4448
Here we have some text at the top of the .cnv file and the data stored after the string END. Each column of the data is described by name 0 for column 1, name 2 for column 1, and so on... How could I extract these names i.e. create a variable named prSM, sal00, t090C respectively? The first hurdle is to extract the variable names, I can worry about extracting the data later. Many thanks.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 2 Nov 2012
Edited: Azzi Abdelmalek on 2 Nov 2012
fid = fopen('yourfile.cnv');
line1 = fgetl(fid);
while ischar(line1)
line1 = fgetl(fid);
res =char(res,line1)
for k=2:4;
Azzi Abdelmalek
Azzi Abdelmalek on 2 Nov 2012
then use for k=2:100
the names are: name{1}, name{2},... .. It's better then name1 name2 ..

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by