From: Gonzalo on 24 May 2010 12:10 Hi there, How can I find en element inside a cell? I mean the row and column?? Say that I have the following: stts = {'Gable','Hip','Shed','Other'}; var = 'Shed' I need to know that var is in position (1,3) of stts. Any ideas??? Thanks
From: Walter Roberson on 24 May 2010 12:18 Gonzalo wrote: > How can I find en element inside a cell? I mean the row and column?? In general you need to use cellfun() > Say that I have the following: > > stts = {'Gable','Hip','Shed','Other'}; > var = 'Shed' > > I need to know that var is in position (1,3) of stts. Any ideas??? That is a special case. [truefalse, index] = ismember('Shed', stts)
From: us on 24 May 2010 12:19 "Gonzalo " <glpita(a)gmail.com> wrote in message <hte8e2$dv6$1(a)fred.mathworks.com>... > Hi there, > > How can I find en element inside a cell? I mean the row and column?? > > Say that I have the following: > > stts = {'Gable','Hip','Shed','Other'}; > var = 'Shed' > > I need to know that var is in position (1,3) of stts. Any ideas??? > > Thanks one of the many solutions s={'a','bb','ccc','ddd'}; t='ccc'; [rn,cn]=find(strcmp(s,t)); disp([rn,cn]); % 1 3 us
From: Nathan on 24 May 2010 12:21 On May 24, 9:10 am, "Gonzalo " <glp...(a)gmail.com> wrote: > Hi there, > > How can I find en element inside a cell? I mean the row and column?? > > Say that I have the following: > > stts = {'Gable','Hip','Shed','Other'}; > var = 'Shed' > > I need to know that var is in position (1,3) of stts. Any ideas??? > > Thanks Assuming stts consists of strings: [x y] = ind2sub(size(stts),find(cellfun(@(x)strcmp(x,var),stts))) %%%%%%%%%% x = 1 y = 3 -Nathan
From: Gonzalo on 24 May 2010 15:44 Thanks a lot guys. It worked perfectly... G Nathan <ngreco32(a)gmail.com> wrote in message <6e9febb1-8a8d-4b75-af01-a84dd68d6020(a)y18g2000prn.googlegroups.com>... > On May 24, 9:10 am, "Gonzalo " <glp...(a)gmail.com> wrote: > > Hi there, > > > > How can I find en element inside a cell? I mean the row and column?? > > > > Say that I have the following: > > > > stts = {'Gable','Hip','Shed','Other'}; > > var = 'Shed' > > > > I need to know that var is in position (1,3) of stts. Any ideas??? > > > > Thanks > > Assuming stts consists of strings: > > [x y] = ind2sub(size(stts),find(cellfun(@(x)strcmp(x,var),stts))) > %%%%%%%%%% > x = > 1 > y = > 3 > > -Nathan
|
Pages: 1 Prev: wavelet padding Next: matlab tool to evaluate mesh quality? |