Trouble using fopen

I am trying to do batch processing. The list of text files to be processed are in a text file which I am able to read into a string. If I try to run fopen again by passing the string as the argument to fopen, fopen fails saying : No such file or directory. Instead, if I hard code the filename in the fopen statement the file is opened successfully.
EDU>> fopen('./nmos_1_50n.dat', 'r')
ans =
5
EDU>> mystring
mystring =
nmos_1_50n.dat
EDU>> [fid2, msg] = fopen(mystring, 'r')
fid2 =
-1
msg =
No such file or directory
Please help.

 採用された回答

Walter Roberson
Walter Roberson 2011 年 4 月 12 日

0 投票

We cannot tell from here whether mystring might have trailing blanks.

1 件のコメント

Sharath
Sharath 2011 年 4 月 15 日
Thanks for your suggestion. I realized I had to remove the trailing blanks using the function deblank()

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by