I am having this error. Could you help?

조회 수: 16 (최근 30일)
Billy Grizz
Billy Grizz 2019년 7월 9일
댓글: Jan 2021년 5월 26일
Error using fopen Unable to find file. Ensure file exists and path is valid.
Error in dlmread (line 120)
[fid, theMessage] = fopen(filename);
Error in Self_Mob_TTB_Code_7_9_19 (line 81)
TTB=dlmread([data_
  댓글 수: 3
Anuradha Gonjari
Anuradha Gonjari 2021년 5월 26일
baseFileName = 'C:\Users\Admin\Desktop\Pritee\apg\download.jpg';
fullFileName = fullfile(pwd,baseFileName);
grayImage = imread(fullFileName);
Jan
Jan 2021년 5월 26일
baseFileName does contain a complete path already. Then appending it to the current folder creates a file path, which does not exist.
FileName = 'C:\Users\Admin\Desktop\Pritee\apg\download.jpg';
% fullFileName = fullfile(pwd,baseFileName); % Nope
grayImage = imread(FileName);

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

답변 (2개)

Jan
Jan 2019년 7월 9일
The error message is clear: You provide a name, which is not an existing file. What is exactly hidden in the omitted rest of:
TTB=dlmread([data_ ... ?
  댓글 수: 3
Billy Grizz
Billy Grizz 2019년 7월 9일
Is there a way to have it give me the name it can not find so I can trouble shoot more?
Jan
Jan 2019년 7월 9일
@Billy: Use the debugger to examine problems. Type this in the command window:
dbstop if error
Then run the code again. When Matlab stops at the error, check the name of the file.
Actually I'd assume, that you can find the contents by reading the code, most of all this line:
TTB=dlmread([data_ ...
If you show us at least the complete line, a more precise suggestion might be possible.

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


Star Strider
Star Strider 2019년 7월 9일
편집: Star Strider 2019년 7월 9일
It is likely better to use the fullfile function than to cd to the path.
I would define ‘keyfile’ as:
keyfile = fullfile(pathname, filename);
and completely remove the cd calls.
EDIT —
If you hare having problems finding the file, You will have to use the operating system to find it if it is not on your MATLAB search path. In Windows, this is the File Explorer utility.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by