Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS_GetIDs returns brace indexing error #54

Closed
LJGz opened this issue Aug 17, 2020 · 5 comments
Closed

TS_GetIDs returns brace indexing error #54

LJGz opened this issue Aug 17, 2020 · 5 comments

Comments

@LJGz
Copy link

LJGz commented Aug 17, 2020

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
@benfulcher
Copy link
Owner

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

@LJGz
Copy link
Author

LJGz commented Aug 27, 2020

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.

@olivercliff
Copy link
Contributor

When the 'Name' option is set, that function only allows one output. Do you have more than one?

@LJGz
Copy link
Author

LJGz commented Sep 1, 2020

Yes I do. I was hoping to filter everything with a particular keyword that exists within the string that within the Name string.

@olivercliff
Copy link
Contributor

That should be fine. Output one argument (only), which will return this list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants