From: RZee Dziyauddin on
Hi;

Does anyone has a clue how to delete the string line from the cell array?

E.g.
'---------- GREEDY_CBR_SEED1.STAT'
'2'
'3'
'4'
'5'
'6'
'7'

I need to delete '--------GREEDY........' line from the cell. How can I do that?
I've tried 'strrep' and it does not meet what I'v expected.

Many thanks.

RZee
From: Steven Lord on

"RZee Dziyauddin" <ujie78(a)yahoo.com> wrote in message
news:huisb8$s76$1(a)fred.mathworks.com...
> Hi;
>
> Does anyone has a clue how to delete the string line from the cell array?
> E.g.
> '---------- GREEDY_CBR_SEED1.STAT'
> '2'
> '3'
> '4'
> '5'
> '6'
> '7'
>
> I need to delete '--------GREEDY........' line from the cell. How can I do
> that?
> I've tried 'strrep' and it does not meet what I'v expected.

The same way you delete an element from any other array.

% If you know the element to delete
c = {'abcde', '2', '3', '4'};
c(1) = []

% or if you know the elements to keep
c = {'abcde', '2', '3', '4'};
c = c(2:4)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: RZee Dziyauddin on
"Steven Lord" <slord(a)mathworks.com> wrote in message <huita8$4ad$1(a)fred.mathworks.com>...
>
> "RZee Dziyauddin" <ujie78(a)yahoo.com> wrote in message
> news:huisb8$s76$1(a)fred.mathworks.com...
> > Hi;
> >
> > Does anyone has a clue how to delete the string line from the cell array?
> > E.g.
> > '---------- GREEDY_CBR_SEED1.STAT'
> > '2'
> > '3'
> > '4'
> > '5'
> > '6'
> > '7'
> >
> > I need to delete '--------GREEDY........' line from the cell. How can I do
> > that?
> > I've tried 'strrep' and it does not meet what I'v expected.
>
> The same way you delete an element from any other array.
>
> % If you know the element to delete
> c = {'abcde', '2', '3', '4'};
> c(1) = []
>
> % or if you know the elements to keep
> c = {'abcde', '2', '3', '4'};
> c = c(2:4)
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>
Tq for your reply. The problem is that I dunno which line the string is. I just read the data from a file and I wanted to remove/delete the string lines and keep the numbers.
I tried below to delete blank lines and it works. Any idea to remove string lines in a file. I do know how to read the files actually.
data = data(~cellfun(@isempty,data));
From: Matt Fig on
Assuming your string always starts with '-'

c(cellfun('isempty',regexprep(c,'^-.*',''))) = []
From: Matt Fig on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <huto8j$7qt$1(a)fred.mathworks.com>...
> Assuming your string always starts with '-'


And if not:

c(~cellfun('isempty',regexpi(c,'[a-z]'))) = []