You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: download_datasets.m
    path of file: ./repos/revisitop/matlab
    
    the code of the file until where you have to start completion: function download_datasets(data_dir)
% DOWNLOAD_DATASETS Checks, and, if required, downloads the necessary datasets for the testing.
%
%   download_datasets(DATA_ROOT) checks if the data necessary for running the example script exist.
%   If not it downloads it in the folder structure:
%     DATA_ROOT/datasets/roxford5k/ : folder with Oxford images
%     DATA_ROOT/datasets/rparis6k/  : folder with Paris images

    
function download_datasets(data_dir)
% DOWNLOAD_DATASETS Checks, and, if required, downloads the necessary datasets for the testing.
%
%   download_datasets(DATA_ROOT) checks if the data necessary for running the example script exist.
%   If not it downloads it in the folder structure:
%     DATA_ROOT/datasets/roxford5k/ : folder with Oxford images
%     DATA_ROOT/datasets/rparis6k/  : folder with Paris images

    % Create data folder if it does not exist
    if ~exist(data_dir, 'dir')
        mkdir(data_dir);
    end

    % Create datasets folder if it does not exist
    datasets_dir = fullfile(data_dir, 'datasets');
    if ~exist(datasets_dir, 'dir')
        mkdir(datasets_dir);
    end