Search code examples
imagematlabvariablesmatlab-load

load a variable in matlab


I want to load variables in a loop with different imagenames.

for i=1:length(imagefile) 
      name=imagefile{i}; 
% name=image01% load name  
end

it looks variable (name) and not (image01), how should I do it regards,


Solution

  • Not sure exactly what your variable is. An array of strings?

    imaefgile = ["image01", "image02"]
    for i=1:length(imaefgile)
        load(imaefgile(i))
    end
    

    P.S. you may also need something like:

    load(strcat("Folder/", imaefgile(i), ".mat"))
    

    to concatenate the filename appropriately.