No file found, when the folder has been found and the file is listed in it

1 回表示 (過去 30 日間)
Nick Aggelopoulos
Nick Aggelopoulos 2020 年 7 月 9 日
コメント済み: Nick Aggelopoulos 2020 年 7 月 16 日
I would be grateful for any suggestions. As the screenshot shows, Matlab has found the folder with the file, it has correctly calculated the file name with the correct suffix, the file name is listed within the folder in the Current Folder window, but an error is instead reported that the file cannot be found.
  4 件のコメント
madhan ravi
madhan ravi 2020 年 7 月 9 日
It might help to see your code from the function file.
Nick Aggelopoulos
Nick Aggelopoulos 2020 年 7 月 9 日
I have added the entire script under Star Strider's response

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

回答 (1 件)

Star Strider
Star Strider 2020 年 7 月 9 日
We cannot see the rest of the function that you are using to read the files (that you apparently wrote, and does not produce any outputs).
Check to see if the logic inside that function is correct. It could be that it is returning the error message when the file itself has been found and read (since no red MATLAB errors apparently appear), and the logic writes the error message in spite of that.
  4 件のコメント
Star Strider
Star Strider 2020 年 7 月 9 日
I obviously cannot test your code. However, note that from the strfind documentation:
k = strfind(str,pattern) searches str for occurrences of pattern. The output, k, indicates the starting index of each occurrence of pattern in str. ’
so (at least as I read it) unless the starting index is 1, This will fail:
strfind(McdDirContent(la).name,fileNam)==1
and ‘nSplit’ will be empty.
Perhaps this would work:
any(strfind(McdDirContent(la).name,fileNam))
As I mentioned, I cannot test this, so you will have to experiment to see if this is actually the problem, and determine what logic works.
It also might be interesting to have your function return something to see if it is doing what you want it to do.
.
Nick Aggelopoulos
Nick Aggelopoulos 2020 年 7 月 16 日
Thanks for your feedback. Just in case this helps anyone, there was a security issue with one of the files or file locations, so that the file could be read but not written into another location. Consequently, the header could not be read by Matlab, hence the program confusingly stated that the original file did not exist.

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

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by