I want to get the image file name without the Extension in MATLAB. I have Tried to use (fileparts )function as:
[pathstr, name, ext, versn] = fileparts(filename);
in this function the (filename) must be with complete Path in order to get the file name without extension in the the variable (name).
when I have just the file name like ('D10_11.jpg'), I get the following Error :
"Input must be a row vector of characters"
Please, if their is another function to solve this problem
From your error message, I guess that the input could be a cell array, rather than a char array.
Thus, instead of
[pathstr,name,ext] = fileparts(filename)
you'd have to write
[pathstr,name,ext] = fileparts(filename{1})
This works fine for me:
>> filename = 'D10_11.jpg';
>> [pathstr,name,ext,versn] = fileparts(filename)
pathstr =
''
name =
D10_11
ext =
.jpg
versn =
''
You should check to make sure filename
is actually what you think it is. The error suggests that it isn't just a row vector of characters like 'D10_11.jpg'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With