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 中查找有关 MATLAB Report Generator 的更多信息
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 (한국어)