files = fullfile(matlabroot, '\toolbox');
So files is a character vector at that point.
Eventually you assign the result of dir() over top of the character vector. But before that, it is a character vector.
[~, f] = fileparts(files(id).name);
And that line is before you assign the result of dir() to files
unzip(fullfile(dinfo(K).folder,dinfo(K).name),selpath);
That tells unzip to write the files into the directory indicated by selpath, which is not likely to be the current directory.
[~, f] = fileparts(files(id).name);
If you were to replace files with a variable that you had assigned the results of a dir() call into, then that line in itself would potentially be valid. It is completely valid to use fileparts() on a character vector that refers to a file that is not in the current directory.
movefile(files(id).name, rf);
If you were to replace files with a variable etc., etc., then the line would still need work.That line requires that the given file is located in the current directory, which will not be the case -- the file is over in selpath
Best Answer