Skip to content
Snippets Groups Projects
Commit c902a288 authored by William Lövfors's avatar William Lövfors
Browse files

Added FindBestParametersFile

parent 6975dc1e
No related branches found
No related tags found
No related merge requests found
function [path,dirStruct] = FindBestParametersFile(pathToSearch)
%FINDBESTPARAMETERSFILE finds the file containing the best parameter set
%based on the name. Assumes that the cost is given in parenthesis.
% [path,name] = FindBestParametersFile(path)
%%
assert(exist(pathToSearch,'dir')>0,'Path does not exist. Are you in the right directory?');
files=dir(pathToSearch);
assert(length(files)>2,'No files to search in the provided path')
names=string({files.name});
values=double(regexprep(names,{'.*\(','\).*'},{'',''}));
assert(any(~isnan(values)),'No files contains valid names. Make sure the files has the cost in parenthesis, e.g opt(12.34)');
[~,bestInd]=min(values);
name=files(bestInd).name;
path=[files(bestInd).folder '\' name];
dirStruct=files(bestInd);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment