フィルターのクリア

Error with movefile function: argument must contain a string

2 ビュー (過去 30 日間)
Heather Riley
Heather Riley 2019 年 9 月 6 日
回答済み: Walter Roberson 2019 年 9 月 6 日
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?

採用された回答

Walter Roberson
Walter Roberson 2019 年 9 月 6 日
{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)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by