MATLAB Answers

I want to read image name to be an string

10 views (last 30 days)
Supwolf
Supwolf on 8 Jan 2020
Commented: Supwolf on 4 Feb 2020 at 12:36
I = imread ("28-30-50-30.jpg");
after I ran this function I will get the image in variable "I",
but I want to read name of this picture ("28-30-50-30.jpg") in string to do the next step in strsprit().
How can I do it??

  4 Comments

Show 1 older comment
Supwolf
Supwolf on 8 Jan 2020
I want this program can change a name of image
it's like I read a file first before get the name of it and sprit them
I = imread('0-0-70-90.jpg');
c = strsplit(I,{'-','.jpg'});
It is error ...
First input must be either a character vector or a string scalar.
Stephen Cobeldick
Stephen Cobeldick on 8 Jan 2020
As you already noted in your question, I is an image. It is a numeric array. It is not a string, nor a character array, and it cannot be applied to functions that require strings or character arrays.
It is not clear what you expect to achieve.
Supwolf
Supwolf on 8 Jan 2020
I want a code to run like this
-first get an image
-next read the name of the image
-then get the name of image
-and sprit them in each alphabet

Sign in to comment.

Accepted Answer

KSSV
KSSV on 8 Jan 2020
imgNames = dir('*.jpg') ;
N = length(imgNames) ;
for i = 1:N
img = imgNames(i).name
end

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.