Error using fopen Unable to find file. Ensure file exists and path is valid.

조회 수: 67 (최근 30일)
PRAGYA ARORA
PRAGYA ARORA 2023년 1월 7일
댓글: Rik 2023년 1월 9일
Error using fopen
Unable to find file. Ensure file exists and path is valid.
The file path is valid and the file is there still unable to read it.
  댓글 수: 4
PRAGYA ARORA
PRAGYA ARORA 2023년 1월 9일
I am facing the same issue with readmatrix/ writematrxi and even while saving the image, these commands used to work properly but somehow creating this error now. Can you suugest something? Thankyou so much.
Rik
Rik 2023년 1월 9일
You should make it a habit to specify the permission when using fopen.
As far as the directory is concerned: you don't specify it, so the current active directory is used. Was that your intention?
When creating files it doesn't matter if the named file exists, since it will be either created or overwritten.

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

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 1월 8일
One of the possible scenarious for such an error might be that your data file is residing in OneDrive (Cloud). Solution is
using addpath(' ...') to add your data file directory accessible by your matlab before recalling your data file.
  댓글 수: 4
Walter Roberson
Walter Roberson 2023년 1월 8일
But most of the time the problem turns out to be that you are trying to open a different file than you think you are opening. Spelling mistakes, wrong directory specified, relative directory was used but you are cd'd to somewhere else. Or from time to time you encounter problems with the file system having been created using a different character set that cannot handle one of the characters you are trying to use.
PRAGYA ARORA
PRAGYA ARORA 2023년 1월 9일
Hi Walter,
Thankyou for your reply, I am using the below code: I am calling the data from my external hard disk.
clc;
close all;
clear all;
p1 = fopen('Mylocation.txt');
a1 = fscanf(p1,'%f\t%f\t%f\n',[3,inf]);
fclose(p1);
final1=a1';
I have checked the directory name, spelling and location sevral times. Still it doesnt open at times, the same code was working for other files in the hard-disk.

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by