Read specific line in Matlab
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Steven Lord
2015-10-5
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!