Uwe Kotyczka

2018-03-08 16:59:15 UTC

Hi,

[Using Matlab2015aSP1]

I have a cell array, say textCells, where each cell contains

a string of the form "keyword = value". For example let

textCells{1,1} = "Gauss_order = 1.1"

textcells{2,1} = "min_Gauss_order = 1.0"

textcells{3,1} = "max_Gauss_order = 2.0"

To parse textCells for a couple of keywords I have search string:

strSearch = 'Gauss_order';

I used the function strfind to find

IndexC = strfind(textCells, strSearch);

Index = find(not(cellfun('isempty', IndexC)));

Works fine for the search string 'min_Gauss_order'.

However for the search string 'Gauss_order' I get three indicees

1,2,3 since each cell contains 'Gauss_order' as a substring.

IndexC has the values

IndexC{1,1} = [ 1]

IndexC{2,1} = [ 5]

IndexC{3,1} = [ 5]

So my idea is to check IndexC for cells containing [ 1] to get only

those cells which start with 'Gauss_order'.

But I can't figure out the correct syntax how to use cellfun for

such a check.

If someone could please give me a hint.

[Using Matlab2015aSP1]

I have a cell array, say textCells, where each cell contains

a string of the form "keyword = value". For example let

textCells{1,1} = "Gauss_order = 1.1"

textcells{2,1} = "min_Gauss_order = 1.0"

textcells{3,1} = "max_Gauss_order = 2.0"

To parse textCells for a couple of keywords I have search string:

strSearch = 'Gauss_order';

I used the function strfind to find

IndexC = strfind(textCells, strSearch);

Index = find(not(cellfun('isempty', IndexC)));

Works fine for the search string 'min_Gauss_order'.

However for the search string 'Gauss_order' I get three indicees

1,2,3 since each cell contains 'Gauss_order' as a substring.

IndexC has the values

IndexC{1,1} = [ 1]

IndexC{2,1} = [ 5]

IndexC{3,1} = [ 5]

So my idea is to check IndexC for cells containing [ 1] to get only

those cells which start with 'Gauss_order'.

But I can't figure out the correct syntax how to use cellfun for

such a check.

If someone could please give me a hint.