TS_GetIDs returns brace indexing error
LJGz opened this issue · 5 comments
Hi Ben,
I get this error when trying to GetIds of a part of name from the Operations.Name table.
When I leave the 'Name' flag out it searches the keywords field and it works fine.
>> OperationIDs = TS_GetIDs('mystring', myFile, 'ops', 'Name');
Loading data from....mat... Done.
Brace indexing is not supported for variables of this type.
Error in TS_GetIDs (line 114)
cmatch = find(contains(theDataTable.Name,theMatchString{i}));
However it works when I use 'contains' below (partially copying the method used in keywords). I'm not sure the reason for the loop in Name using cmatch?
case {'name','Name'}
% The cell of comma-delimited keyword strings:
theKeywordCell = theDataTable.Name;
% Find objects with a keyword that matches the input string:
matches = find(contains(theKeywordCell, theMatchString));
% Return the IDs of the matches:
IDs = theDataTable.ID(matches);
% Check for empty:
if isempty(IDs)
warning('No matches to ''%s'' found in %s',theMatchString,theDataFile)
end
I seems that 'Name'
mode (which @olivercliff added) assumes a cell of strings, so it fails when you input a string (the name theMatchString
is deceptive due to the double-use of this input with 'Keyword'
mode, as originally intended.
Hopefully the latest commit fixes this: 4056ea7
It still isn't working for me. It returns the error
Error using TS_GetIDs (line 119)
One output argument (IDs) required for 'Name' input.
I guessed that it might be the switch should be 0 on assert(nargout == 1,'One output argument (IDs) required for ''Name'' input.')
Changing it to 0 resulted in
Warning: No matches to the 1 input strings found in D:\myfile
> In TS_GetIDs (line 140)
I tried it both with the examples given
line 127 cmatch = find(strcmp(theDataTable.Name,theMatchString{i}));
compares strings, however I if they are not an exact it will return empty. The only way to get a result is if theMatchString{i} is exactly the same not as per the example 'length'.
Sorry I don't know how to re-open an issue.
When the 'Name' option is set, that function only allows one output. Do you have more than one?
Yes I do. I was hoping to filter everything with a particular keyword that exists within the string that within the Name string.
That should be fine. Output one argument (only), which will return this list