Error with movefile function: argument must contain a string

2 Ansichten (letzte 30 Tage)
I am trying to use the movefile(filename, directory_pathway) function to move an image file into a different folder. I am using Matlab R2014a. When I run my program I get the following error: Argument must contain a string.
Here is my code:
function dataset_randomisor()
% Set data path (the folder in which the dataset is currently stored)
data_path = 'E:\20190618-f1\images_extracted_from_zebrafish_movies\20190618-f1_10-27-56';
training_dataset_path = 'E:\20190618-f1\images_extracted_from_zebrafish_movies\training_dataset';
% Find images
images = dir(data_path);
% Randomly select 100 images
for k=1:100
img_index = randi(length(images));
random_image = images(img_index);
images(img_index) = []; % remove the selected image so that it doesn't get selected twice
movefile({random_image.name},training_dataset_path);% move the selected image to the training dataset
end
end
Does anyone know what I'm doing wrong, and/or how I can fix it?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Sep. 2019
{random_image.name} is a cell array with a character vector inside it. That name does not include the directory either
fullfile(data_path, random_directory.name)

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by