Azzera filtri
Azzera filtri

Error with movefile function: argument must contain a string

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 6 Set 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)

Più risposte (0)

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Prodotti


Release

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by