이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Unable to read file 'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0shearletSystem4.mat'. No such file or directory.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hellow everyone!
I am running a code to detect the fractures from image, in the mide of code, it asks me to load the mat file generated by this function, the mat file is present in the folder but still giving me an error that no file exisit.
Any suggestion?
댓글 수: 2
Kevin Holly
2021년 9월 30일
If you drag the file into the command window, does it provide the same file path when it loads?
Omer Iqbal
2021년 9월 30일
No, it does not give the complete path ( Please snapshot) , i have also tried to change the path as well.
답변 (2개)
Image Analyst
2021년 10월 1일
Run this code.
topLevelFolder = 'C:\Users\Omer\Documents\MATLAB';
filePattern = fullfile(topLevelFolder, '**\*.mat')
fileList = dir(filePattern)
% Loop over them.
numFiles = length(fileList);
for k = 1 : numFiles
thisFileName = fullfile(fileList(k).folder, fileList(k).name);
fprintf('File #%d of %d :\n "%s"\n', k, numFiles, thisFileName);
% Get size info if desired
d = dir(thisFileName);
fprintf(' It is %d bytes.\n', d.bytes);
s = load(thisFileName)
end
What do you see in the command window?
댓글 수: 9
Omer Iqbal
2021년 10월 1일
Should I use your code instaead of fileName = fullfile(outfolder, "shearletSystem" + i + ".mat")
load(fileName). Well, I used your code in command window and have got the following information;
K>> topLevelFolder = 'C:\Users\Omer\Documents\MATLAB';
filePattern = fullfile(topLevelFolder, '**\*.mat')
fileList = dir(filePattern)
% Loop over them.
numFiles = length(fileList);
for k = 1 : numFiles
thisFileName = fullfile(fileList(k).folder, fileList(k).name);
fprintf('File #%d of %d :\n "%s"\n', k, numFiles, thisFileName);
% Get size info if desired
d = dir(thisFileName);
fprintf(' It is %d bytes.\n', d.bytes);
s = load(thisFileName)
end
filePattern =
'C:\Users\Omer\Documents\MATLAB\**\*.mat'
fileList =
9×1 struct array with fields:
name
folder
date
bytes
isdir
datenum
File #1 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0shearletSystem1.mat"
It is 23127 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #2 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0shearletSystem2.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #3 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0shearletSystem3.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #4 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0shearletSystem5.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #5 of 9 :
"C:\Users\Omer\Documents\MATLAB\smallimg.mat"
It is 486 bytes.
s =
struct with fields:
img: [10×10×3 uint8]
File #6 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\Automatic-Fracture-Detection-Code-1.0.0shearletSystem4.mat.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #7 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\shearletSystem1.mat"
It is 23127 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #8 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\shearletSystem2.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
File #9 of 9 :
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\shearletSystem3.mat"
It is 23165 bytes.
s =
struct with fields:
shearletSystem: [1×1 struct]
K>>
Image Analyst
2021년 10월 2일
OK, now we're getting somewhere. It's definitely finding your files now. Now you simply need to get the variable from the structure and do something with it.
topLevelFolder = 'C:\Users\Omer\Documents\MATLAB';
filePattern = fullfile(topLevelFolder, '**\*.mat')
fileList = dir(filePattern)
% Loop over them.
numFiles = length(fileList);
for k = 1 : numFiles
thisFileName = fullfile(fileList(k).folder, fileList(k).name);
fprintf('File #%d of %d :\n "%s"\n', k, numFiles, thisFileName);
% Get size info if desired
d = dir(thisFileName);
fprintf(' It is %d bytes.\n', d.bytes);
s = load(thisFileName)
% Get the shearletSystem structure:
shearletSystem = s.shearletSystem;
% Now do something with shearletSystem.....
end
What do you want to do with the shearletSystem variable?
Omer Iqbal
2021년 10월 2일
Hi!
It didnot give me an error of missing file, it generated the file and have managed to load the mat files. It seems the issue has been resolved. However, after using your code, I gor another error of incomplete input arguments in another related functions. Please have a look in snapshot and see the informtaion below that I got after using your code;
Unrecognized field name "shearletSystem".
17 X = fftshift(fft2(ifftshift(X)));
>> CSHRMsheardec
Not enough input arguments.
Error in CSHRMsheardec (line 17)
X = fftshift(fft2(ifftshift(X)));
K>>
Image Analyst
2021년 10월 2일
One of your mat files does not have that variable in it. You might need to adjust your file pattern, like
filePattern = fullfile(topLevelFolder, '**\sh*.mat')
or something.
Omer Iqbal
2021년 10월 2일
I am getting the same error after adjsuting the file pattern using your code (filePattern = fullfile(topLevelFolder, '**\sh*.mat'). Please see the following information and snapshot;
CSHRMsheardec
filePattern =
'C:\Users\Omer\Documents\MATLAB\**\sh*.mat'
Not enough input arguments.
Error in CSHRMsheardec (line 18)
X = fftshift(fft2(ifftshift(X)));
K>>
Omer Iqbal
2021년 10월 4일
편집: Walter Roberson
2021년 10월 4일
I am using someone' else codes, I am trying to use inverse fourier trasnform and fourier trasnform shift on deveopled shearlets. I am not quite familiar on how to implement fftshift , fft2 and ifftshift. Below are the codes that I am trying to use. Additionally, there are some other functions which depend on these codes as well. X must be shearlets!
X = fftshift(fft2(ifftshift(X)));
for k = 1:contShearletSystem.nShearlets
coeffs(:,:,k) = conj(fftshift(ifft2(ifftshift(X.*conj(contShearletSystem.nshearlets(:,:,k))))));
end
Image Analyst
2021년 10월 4일
When you do
X = fftshift(fft2(ifftshift(X)));
it takes X and does operations on it and puts it back into X. So X must exist already. You must define it before you call that line.
Walter Roberson
2021년 10월 4일
The error messages show that CSHRMsheardec needs to be called with at least one parameter, that it refers to as X, but that you ran the function with no parameters -- for example you might have pressed the green Run button instead of going down to the command line and invoking the function passing in values.
Walter Roberson
2021년 9월 30일
Do not use strcat() to create the path like that: you are missing a directory separator. Use
load( fullfile(outfolder, sheerletSystem, i + ".mat") )
댓글 수: 18
Walter Roberson
2021년 10월 1일
At the time of the error, please show us
pwd()
ls()
filenane = fullfile(outfolder, sheerletSystem, i + ".mat")
exist(filename)
Omer Iqbal
2021년 10월 1일
편집: Image Analyst
2021년 10월 1일
I got the following information. Please also see attached snapshot.

pwd
ans =
'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0'
K>> filenane = fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
filenane = fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
↑
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
K>> filenane = fullfile(outfolder, 'shearletSystem',num2str(i),'.mat')
filenane =
'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\shearletSystem\1\.mat'
K>> exist(filename)
Image Analyst
2021년 10월 1일
편집: Image Analyst
2021년 10월 1일
OK, filenane is a different variable than filename. The first one does not have an "m" in it.
Try this:
workspace; % Show all variables
fileName = fullfile(outfolder, 'shearletSystem',num2str(i),'.mat')
isfile(fileName)
Omer Iqbal
2021년 10월 1일
I have got following information;
K>> workspace; % Show all variables
fileName = fullfile(outfolder, 'shearletSystem',num2str(i),'.mat')
isfile(fileName)
fileName =
'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\shearletSystem\1\.mat'
ans =
logical
0
Walter Roberson
2021년 10월 1일
fileName = fullfile(outfolder, sheerletSystem, i + ".mat")
Notice I do not use num2str(). Notice no comma between the i and the .mat . Notice I use + ".mat" which is string() concatenation
Is there a particular reason to use num2str(i) instead of using the way I show? For example are you using R2016b or earlier, in which case you might have problem access string() objects ?
Omer Iqbal
2021년 10월 1일
I am using R2021a. I tried to use your code but it didnot work, please see the information below that I got using your code:
workspace; % Show all variables
fileName = fullfile(outfolder, sheerletSystem, i + ".mat")
isfile(fileName)
Unrecognized function or variable 'sheerletSystem'.
188 load( fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
K>> workspace; % Show all variables
fileName = fullfile(outfolder, sheerletSystem, i + ".mat")
isfile(fileName)
Unrecognized function or variable 'sheerletSystem'.
188 load( fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
Walter Roberson
2021년 10월 1일
fileName = fullfile(outfolder, 'sheerletSystem', i + ".mat")
load(fileName)
Omer Iqbal
2021년 10월 1일
load( fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
K>> fileName = fullfile(outfolder, 'sheerletSystem', i + ".mat")
load(fileName)
fileName =
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem\1.mat"
Error using load
Unable to read file 'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem\1.mat'. No such file or
directory.
188 load( fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'));
K>>
Walter Roberson
2021년 10월 1일
Now I am confused about your directory structure. Please show
ls('C:\Users\Omer\Documents\MATLAB\*.mat')
ls('C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\*.mat')
ls('C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem\*.mat')
Omer Iqbal
2021년 10월 1일
I have got following information for each code:
K>> ls('C:\Users\Omer\Documents\MATLAB\*.mat')
Automatic-Fracture-Detection-Code-1.0.0shearletSystem1.mat Automatic-Fracture-Detection-Code-1.0.0shearletSystem5.mat
Automatic-Fracture-Detection-Code-1.0.0shearletSystem2.mat smallimg.mat
Automatic-Fracture-Detection-Code-1.0.0shearletSystem3.mat
K>> ls('C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\*.mat')
Automatic-Fracture-Detection-Code-1.0.0shearletSystem4.mat.mat shearletSystem3.mat
shearletSystem1.mat
shearletSystem2.mat
K>> ls('C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem\*.mat')
No matches for pattern 'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem\*.mat'.
K>>
Walter Roberson
2021년 10월 1일
If I have followed everything properly,
fileName = fullfile(outfolder, "sheerletSystem" + i + ".mat")
load(fileName)
Omer Iqbal
2021년 10월 1일
Yes, you have mentioned all the information; but I am still getting the error, please see below;
fileName = fullfile(outfolder, "sheerletSystem" + i + ".mat")
load(fileName)
fileName =
"C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem1.mat"
Error using load
Unable to read file 'C:\Users\Omer\Documents\MATLAB\Automatic-Fracture-Detection-Code-1.0.0\sheerletSystem1.mat'. No such file or
directory.
188 load( fullfile(outfolder, 'shearletSystem',num2str(i),'.mat'))
Walter Roberson
2021년 10월 1일
fileName = fullfile(outfolder, "shearletSystem" + i + ".mat")
load(fileName)
"shear" instead of "sheer" ...
Omer Iqbal
2021년 10월 1일
After using your code above, I am getting a new error along with the load error. Please see snapshot and information below;
lapsed time is 0.027184 seconds.
Computing complex shearlet system based on the inputs for combination number: 3
Elapsed time is 0.022526 seconds.
Elapsed time is 0.022632 seconds.
The total number of ridge realizations is: 1750
Select multiple image files (they must be in a single folder)
You have selected 1 images
Error using fullfile (line 67)
All inputs must be strings, character vectors, or cell arrays of character vectors.
Error in Ridge_Ensemble_Generator (line 188)
load(fullfile(outfolder, shearletSystem, i + ".mat"));
67 error(message('MATLAB:fullfile:InvalidInputType'));
K>>
Omer Iqbal
2021년 10월 1일
When I used in command window, I got follwoing information;
K>> fileName = fullfile(outfolder, "shearletSystem" + i + ".mat")
load(fileName)
Unrecognized function or variable 'outfolder'.
67 error(message('MATLAB:fullfile:InvalidInputType'));
K>>
Walter Roberson
2021년 10월 4일
I do not seem to find a complete posting of your code, for us to see where you define outfolder . In the previous comments, you never posted that part so we just had to assume that you had already defined it.
Omer Iqbal
2021년 10월 11일
Hi !
Thanks for helping me ! I managed to run the functions. The X was supposed to estimate using some other linked functions.
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)