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

1 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by