%https://github.com/cbdavis/MatlabSPARQL/blob/master/sparql.m

endpointUrl = '{ENDPOINT_URL}';
sparqlQuery = {SPARQL_QUERY};

url_head = strcat(endpointUrl,'?query=');
url_query = urlencode(sparqlQuery);
format = 'text/tab-separated-values';
url_tail = strcat('&format=', format);

url = strcat(url_head, url_query, url_tail);

% get the data from the endpoint
query_results = urlread(url);

% write the data to a file so that tdfread can parse it
fid = fopen('query_results.txt','w');
if fid>=0
    fprintf(fid, '%s\n', query_results)
    fclose(fid)
end

% this reads the tsv file into a struct
sparql_data = tdfread('query_results.txt')
