Why does the importdata function read in my file data incorrectly when reading data from a .mp file
1 view (last 30 days)
Show older comments
Sean Byrne
on 23 Nov 2016
Answered: Walter Roberson
on 23 Nov 2016
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
0 Comments
Accepted Answer
Walter Roberson
on 23 Nov 2016
fid = fopen(filename, 'rt');
datacell = textscan( fid, '%s=%f' );
fclose(fid)
textdata = datacell{1};
data = datacell{2};
0 Comments
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data 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!