Why does the importdata function read in my file data incorrectly when reading data from a .mp file

1 vue (au cours des 30 derniers jours)
When I run the function MyData = importdata(filename); I am getting an issue with how the data is reading in.
In the created MyData variable I should now have 2 new fields textdata and data which should be defined by the ' ' delimiter and their values/text.
Below is a breakdown of my code + data and the outputs I'm getting if anyone can help or has had this type of issue before?
Here's an example of what the data from the .mp file looks like as a text file
$Female = 0
$Adult = 1
$Height = 1885
$BodyMass = 71.8
$SamplingRate = 250
Instead of breaking the data up into the appropriate sections based on the ' ' delimiter it does this for textdata
'$Female ='
'$Adult = 1'
'$Height = 1'
'$BodyMass ='
And this for data
0
NaN
885
71.8000000000000

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Nov 2016
fid = fopen(filename, 'rt');
datacell = textscan( fid, '%s=%f' );
fclose(fid)
textdata = datacell{1};
data = datacell{2};

Plus de réponses (0)

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by