myver = ver; myver(1:5).Name 

returns:

ans = 'Computer Vision System Toolbox' ans = 'Control System Toolbox' ans = 'Curve Fitting Toolbox' ans = 'DSP System Toolbox' ans = 'Database Toolbox' 

Stringfind

strfind(myver(1:35).Name,'Toolbox') 

Returns the error:

Error using strfind Unrecognized parameter name 'Curve Fitting Toolbox'. 

I am seeking a list of all entries with the word 'Toolbox'. Why does strfind err on the third entry?

Any feedback or edits that sharpen the question are appreciated.

1 Answer

myver(1:5).Name returns a comma-separated list.

strfind(myver(1:5).Name,'Toolbox') is the same as:

strfind('Computer Vision System Toolbox', 'Control System Toolbox', ... 'Curve Fitting Toolbox', 'DSP System Toolbox', 'Database Toolbox', 'Toolbox'); 

Clearly this is invalid syntax. Read the documentation of the strfind function to see the valid syntax.

You need to combine this comma-separated list's elements in a cell-array before applying strfind i.e:

tmpVar = {myver(1:35).Name}; %concatenating the list into a cell-array check = strfind(tmpVar,'Toolbox'); %finding which cells contain 'Toolbox' logidx = ~cellfun(@isempty,check); %logical indices of the cells which contain 'Toolbox' tmpVar{logidx} %Required result (as a comma-separated list) 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy