Filtering Matlab Results with Strfind
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

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

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest