this is the code and i have no idea why it's not workinng
y=audioread('Arabic_Male_Alain_G_Corp');
Error using audioread (line 74)
The filename specified was not found in the MATLAB path.
Is this file located in your active folder? If not, you need to specify the full filepath (e.g. C:\...)
Related
I am trying to run a teaching tutorial on Fourier space in MRI image generation, and consistently getting the following error:
Error using openfig
Too many input arguments.
Error in k_space_tutorial (line 20)
fig = openfig(mfilename, 'reuse')
I have made sure that the folder with the code and related files is in the directory:
>> isdir('k_Space_tutorial_David_Moratal')
ans =
logical
1
and in the path:
>> path
MATLABPATH
C:\Users\Myname\Documents\MATLAB
These are the contents of the directory:
>> dir
. half_fov.m openfig.m
.. image_test.bmp rectangular_matrix.m
README.txt imatge_i_espai_k_originals.m replay_pid10644.log
add_awgnoise.m k_space_tutorial.fig replay_pid11732.log
filtre_pas_alt.m k_space_tutorial.m replay_pid13344.log
filtre_pas_baix.m modaldlg.fig
half_fourier_fe.m modaldlg.m
half_fourier_pe.m motion_artifacts.m
Results of the debugger:
openfig is a function that comes with MATLAB, and according to its documentation, the syntax used is correct.
One of the possible reasons for a function being called correctly but leading to an error is that a different function is called inadvertently. This happens when a different function with the same name shadows (hides) the original function. An M-file in the current directory, or in an earlier directory on the path, with the same name will cause this.
Typing which openfig at the MATLAB command prompt will tell you what function is called when that name is used.
In this case, there is an M-file in the current directory with the same name. Deleting this file (or renaming it) will solve the problem.
I'm trying to open images with imread but it keEps telling me that the files do not exist.
Here's the message from the command window
Error using imread>get_full_filename (line 516)
File "Pic1.jpg" does not exist.
Error in imread (line 340)
fullname = get_full_filename(filename);
Error in ImageDetection (line 2)
img1 = imread('Pic1.jpg');
And here are the sections of code that it's referencing from the function itself
if (fid == -1)
if ~isempty(dir(filename))
% String 'Too many open files' is from strerror.
% So, no need for a message catalog.
if contains(errmsg, 'Too many open files')
error(message('MATLAB:imagesci:imread:tooManyOpenFiles', filename));
else
error(message('MATLAB:imagesci:imread:fileReadPermission', filename));
end
else
error(message('MATLAB:imagesci:imread:fileDoesNotExist', filename));<--LINE 516
end
if isempty(fmt_s)
% The format was not specified explicitly.
% Get the absolute path of the file
fullname = get_full_filename(filename); <--LINE 340
Image isn't in Current Directory (Or Path)
If your image is in your working directory, you can call it by its name ("Pic1.jpg"). However, MATLAB doesn't search all folders on your computer. If, for example, if your program is running in C:\Users\user\Documents\MATLAB, and the image is in C:\Users\user\Pictures, you could reference the picture using:
Absolute paths ("C:\Users\user\Pictures\Pic1.jpg")
Relative paths ("..\..\Pictures\Pic1.jpg")
Usually, if the pictures only exist because of your program, it'd be somewhere in the same directory, so you wouldn't need to use ".." to move up any directories.
If you want the user to be able to select a picture each time the program is run, I'd recommend looking into uigetfile. If you want to know more about where MATLAB searches for files, see this article.
Secondly, you may want to check your file name. While it seems obvious, a simple misspelling can be hard to notice at times, for example "Pic1.jpg" vs "Pic1,jpg" vs "Pic1.jpeg"
Just above the line of your code where the error occurs, write a new line:
dir
To output in the prompt the files of the current folder, and check that the name of your file exactly appears there. Could you copy us that output?
I have a file with name test.net. I put it in the same location as the matlab working directory. Then, I put the following two lines of codes.
path='test.net';
[pajekFile,errmsg] = fopen(path);
The errmsg is: "No such file or directory". Does anyone know what is going on here?
I have the absolute path of an image myabspath
D:\myimages\venus\surface\im0012.jpg
I have tried
im=imread(myabspath);
but doesn't work because seems that imread accept only the name of a file in the current working directory.
I have also tried
f=load(myabspath);
But get an error "Argument must contain a string".
Seems a pretty basilar operation but unfortunately I haven't found the solution.
EDIT
Seems that the problem is caused by the fact myabspathis not a regular String but a cell, I have tried to use
myabspath=cellstr(myabspath)
but I continue to receive the error that tell me that myabspath is not a string, but if I call
display(myabspath)
I see the right path. Any solution?
If you have a cell that contains the String path, you don't need any conversion, is enough access the content of the cell using {index}.
Eg
if you have to get the first element use myabspath{1}
imread is able to read images from absolute paths
It seems strange.
Did you get a specific error message?
Does the image actually exists?
Did you, perhaps, write a "your own" imread function which overrides the "MatLab" one?
According to MatLab (R2012b) help, imread also accepts "full pathname"
imread Read image from graphics file.
A = imread(FILENAME,FMT) reads a grayscale or color image from the file
specified by the string FILENAME. If the file is not in the current
directory, or in a directory on the MATLAB path, specify the full
pathname.
I've replicated your folder structure, I did not add it to the MatLab path, nevertheless and I've been able to read an image with imread by specifying the full pathname.
This is the output I've got:
>> myabspath='D:\myimages\venus\surface\im0012.jpg'
myabspath =
D:\myimages\venus\surface\im0012.jpg
>> im=imread(myabspath);
>> whos
Name Size Bytes Class Attributes
im 421x500x3 631500 uint8
myabspath 1x36 72 char
I have a data folder in /home/me/project/data that contains image files. In project is my script. I wish to imread all the images in this file. When I do the following dirData = dir('.\data\*.jpg'); I get Error using imread (line 349). Is there a way to refer to this directory without having to specify the full path?