Read specific line in Matlab

조회 수: 1 (최근 30일)
Anders Bennedsgaard
Anders Bennedsgaard 2015년 10월 5일
댓글: Anders Bennedsgaard 2015년 10월 5일
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?

답변 (1개)

Steven Lord
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.
  댓글 수: 1
Anders Bennedsgaard
Anders Bennedsgaard 2015년 10월 5일
Yeeah, i kinda figured that out by now.. But it was just a quickly made script..
Also, i've tried to use the excact same file called 21speed.txt, and that one worked fine. I've read that numbers and underscores cant be the first thing in the name, but when i removed the underscore, it worked like a charm.. I've got over 500 data-sets..

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by