Error from fopen after conflicting files/paths

3 ビュー (過去 30 日間)
z8080
z8080 2020 年 10 月 2 日
編集済み: z8080 2020 年 11 月 24 日
I have a script that, at the end, writes the generated figure to an image file:
fileName = 'figureOne';
print('-dpng', fileName );
This has been working without problems, but now the print command generates the error
Error using fopen
The file name contains characters that are not contained in the filesystem encoding.
Certain operations may not work as expected.
Error in name (line 84)
fidread = fopen(pj.FileName,'r');
Error in print (line 85)
pj = name( pj );
Error in print
Clearly there are no unacceptable characters in the file name. This other thread suggested a couple of fixes, but none of them seem to be the case. In particular, the commands
get(0, 'Language')
locale = java.util.Locale.getDefault()
language = locale.getLanguage()
return
ans =
en_GB
locale =
en_GB
language =
en
..but I doubt the problem is with the last one being just 'en' and not 'en_GB'. Rather, what has very likely caused this (though I don't know exactly how) was me having recently copied over (with overwrite) some .m files into Matlab's directory (under toolboxes etc), from another installation (2016a). A symptom of it is the warnings that I get when starting Matlab, for several functions, such as:
Warning: Function license has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
But fopen is not among them, and I am not sure what to change to solve my current problem. Would very much appreciate any help with this!
  2 件のコメント
Stephen23
Stephen23 2020 年 10 月 3 日
"what has very likely caused this... was me having recently copied over (with overwrite) some .m files into Matlab's directory (under toolboxes etc), from another installation..."
Doing that is the source of hidden, latent, unpredictable, almost-impossible to debug problems and bugs that will plague you forever more. There is NO way to ensure that any function or class can or does behave as documented, basically now you will never know if anything behaves as documented.
You should just reinstall.
And in future, NEVER save your own functions (copied from anywhere) in any installation folder of any application.
z8080
z8080 2020 年 10 月 4 日
編集済み: z8080 2020 年 11 月 24 日
That's a particularly dramatic way of putting it Stephen Cobeldick, but yes, a mistake I will not repeat... :-D

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

採用された回答

z8080
z8080 2020 年 10 月 3 日
編集済み: z8080 2020 年 10 月 5 日
Apparently there is an easy (albeit superficial - note Stephen's answer!) fix for this, which I've been advised to do: issue the command restoredefaultpath.
This has temporarily fixed the problem for me, although the command does need to be reissued after every restart of Matlab. Might be that then using savepath as WR suggests below, mitigates it.
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 4 日
You could try
savepath
after restoring the path.
z8080
z8080 2020 年 10 月 5 日
Indeed, that's helpful, thanks.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 10 月 2 日
me having recently copied over (with overwrite) some .m files into Matlab's directory (under toolboxes etc), from another installation (2016a)
You need to reinstall MATLAB.
Sorry, but it is not worth the time to pinpoint exactly which part of MATLAB you broke.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by