Effacer les filtres
Effacer les filtres

Error with movefile function: argument must contain a string

2 vues (au cours des 30 derniers jours)
Heather Riley
Heather Riley le 6 Sep 2019
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 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)

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by