Direc(1).name is a [1 x N] char vector, also called a "string". You try to assign it to the scalar Direcname(1). But you cannot store a vector in a scalar.
You can store string in a cell:
...
Direcname{i} = Direc(i).name;
...
Consider the curly braces.
The loop can be omitted:
Direc = dir('KR5');
Direcname = {Direc(i).name};
Btw. clear all deletes all loaded functions from the memory. This does not have any advantage, but the reloading needs a lot of time. clc is not helpful here also.
Adding the current folder and all subfolders to the Matlab path might be useful for any purpose, but for the shown problem it does not help. Better use the absolute path of "KR5", see help fullfile.
Best Answer