I need to create two test and train folder from one parent folder (in the same directory), I wrote the code, but file couldn't be moved. Please Help!!
    조회 수: 1 (최근 30일)
  
       이전 댓글 표시
    
files = dir('*.jpg');
N=numel(files);
tf = randperm(N) > (0.80 *N);
TF=tf';
mkdir  Test
mkdir  Train
for i=1:1:N
    filename = files(i).name;
    A = imread(filename);
    image=imshow(A);
    if TF(i)==1
        movefile(image, Train)
    else
        movefile(image, Test)
    end
end
댓글 수: 0
채택된 답변
  Stephen23
      
      
 2021년 5월 13일
        P = 'absolute/relative path to where the files are saved';
S = dir(fullfile(P,'*.jpg'));
N = numel(files);
B = randperm(N) > (0.80*N);
mkdir('Test')
mkdir('Train')
for k = 1:N
    F = files(i).name;
    if B(k)
        movefile(fullfile(P,F),fullfile(P,'Train',F))
    else
        movefile(fullfile(P,F),fullfile(P,'Test',F))
    end
end
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

