textread behaves differently when file resaved

Hello,
I have a not standard format (MRI scanner) file for which I use textread function to read the header. When I use the following command directly on the file, I do not get the full content of the file:
textread('foo','%s', 'delimiter','\n','bufsize', 500000);
However, if I open the file in matlab text editor, make some change, save the file, undo the change and re save it, I get different output (which is correct).
I am assuming there is some problem with the format it was saved originally.
Can anyone help me understand this problem ?
Thanks, Akshay

 採用された回答

Akshay Jain
Akshay Jain 2015 年 3 月 12 日

0 投票

Couldn't figure out the real reason for the problem, but using textscan in place of textread solved it.

その他の回答 (3 件)

Jan
Jan 2015 年 3 月 6 日

0 投票

It is impossible to guess the differences between the two files. But you can find them. Save the modified file under a new name and use the tool of the editor to compare files. Or e.g. WinDiff or a similar tool.
Akshay Jain
Akshay Jain 2015 年 3 月 6 日

0 投票

Thanks. I tried comparing them using Kdiff but they look exactly same. Actually there are some differences but I am guessing that's because of some non text (binary, so text editors read them as special characters) information stored in the two files. I could have posted the files, but I am not sure if I am allowed to.
I am thinking of a work around, is there a way I can open the files using some command, edit first line and re save them ? Just to get it working.
Akshay Jain
Akshay Jain 2015 年 3 月 6 日

0 投票

Another observation, it only works when I open, edit, save, undo, re save in matlab text editor. I tried doing the same thing in notepad, but it doesn't help. So apparently Matlab is doing something while saving it.

カテゴリ

ヘルプ センター および File ExchangeLanguage Support についてさらに検索

タグ

質問済み:

2015 年 3 月 6 日

編集済み:

2015 年 3 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by