How to get the indices of specified name

Hi,
I have below cell array
Mek989.0
YTG873.0
RFD645.0
RFD645.0
WER134.0
WER134.0
my specified name:RFD645.0, and I want to find the indices of rows which is not "RFD645.0" here in this case, row1,2,5,6. My desired output is:
1
2
5
6

 Accepted Answer

C = {'Mek989.0';
'YTG873.0';
'RFD645.0';
'RFD645.0';
'WER134.0';
'WER134.0'};
output = find(not(ismember(C,'RFD645.0')));

7 Comments

Sir, Thanks, it works, I want bit more, I want to get the index of first not a memebr row. In this case, the index is 1 becasue the first name is not RFD645.0
Sir,
This is ok, but any other way to get it in one line. My input is
C = {'Mek989.0';
'YTG873.0';
'RFD645.0';
'RFD645.0';
'WER134.0';
'WER134.0'};
I want to get the index of first apperence of "RFD645.0"(in this case is 3) I use the below syntax, but is doesn't work for cell array
ix = find(C==RFD645.0, 1, 'first');
find(strcmp(C,'RFD645.0'),1,'first')
Sorry Sir, I have one more last question, I use the below command:
indx=find(strcmpi(C,'RFD645.0',1,'first')
Lastly, I want to use it for "not condition" the condition which is different from "RFD645.0"
Thanks a lot Sir, and very very sorry to ask continuous questions
You mean you want to find the first element that does not match?
indx=find(not(strcmpi(C,'RFD645.0')),1,'first')
Yes, It works, perfect. Thanks a lot.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!