Read specific line in Matlab
2 views (last 30 days)
Show older comments
I have a textfile with some data, which i've made in MatLab with the fwrite-command. Only, now i've discovered i need to use those data again, and i'm not entirely sure how to import it again, and only read one specific line. I've found some commands to do this like 'fileread', but i'm not sure how to use it. My textfile i'm trying to import again, is something looking like this:
General model:
VA1(x) = a*x+b
Coefficients (with 95% confidence bounds):
a = -0.0191 (-0.04125, 0.003042)
b = 0.2261 (0.2056, 0.2466)
I'm trying to get the values for a, in again.
As a sidenote: This data is called '2_1speed.txt', but when i'm trying to import this using 'fopen', it shows an error, because of the underscore. Is there a way to still import it, with the underscore in the name of the file?
0 Comments
Answers (1)
Steven Lord
on 5 Oct 2015
Rather than writing the fit object's displayed text to a text file, next time consider saving the object itself to a MAT-file. Then you could use COEFFVALUES on that object to retrieve the full precision value of that parameter, rather than the truncated version included in the displayed text.
FOPEN should be able to handle files with underscores in the name. Call FOPEN with two outputs and check the second output to see what it says is the problem with opening that file.
See Also
Categories
Find more on Text Files 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!