0

I have a cell array like this:

'10 Hz: Time_abs'
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
'10 Hz: Time_abs'
<1x2 cell>
<1x2 cell>
<1x2 cell>

At first I need to find in which rows there is 10 Hz: Time_abs and then delete the corresponding row. I cannot use strcmp because the other rows are <1x2 cell>.

Can anybody help me with that?

1
  • 1
    Don't you mean {1x2 cell} instead? If so, strcmp worked for me. Commented Apr 27, 2014 at 22:08

2 Answers 2

2

You can iterate cell by cell and check for being string using isstr function, for instance:

A{1} = 'sdadfadf';
A{2} = 23;
A{3} = [1,2,3,4];
A{4} = 0;


for ii=1:length(A)
isstr(A{ii})
end

ans =  1
ans = 0
ans = 0
ans = 0

The other solution is using ischar function:

C{1,1} = magic(5);
C{1,2} = 'John Dump';
C{1,3} = 1 + 1i     
C{1,4} = 0.0025

for k = 1:4
x(k) = ischar(C{1,k});
end

x

x =

     0     1     0    0
Sign up to request clarification or add additional context in comments.

Comments

0

In one line:

C{1,1} = magic(5);
C{1,2} = 'John Dump';
C{1,3} = 1 + 1i     
C{1,4} = 0.0025

x = cellfun(@ischar, C)

x =

     0     1     0    0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.