I would like to do something like the following, except I just want to delete 'G' and 'G' because they are duplicates One after the other
Any help will be appreciated !!!
I have this cell array in MATLAB:
Y = {'d' '' F '' 'A' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' 'My first answer (below) had an error in using multiple duplicates (thanks) / code> < / Pre>
grantnz). Here's an updated version:
& gt; & Gt; Y = {'d' f '' a 'g' g 'y' 'a' 'h' h 'i' '' '' '' '' ''; & Gt; & Gt; I = search (diff (char (y)) == 0); & Gt; & Gt; Y ([i, i + 1]) = [] y = 'd' 'f' 'a' 'w' 'a' j '
Old Answer If your "cell vector" contains only one character element, then you can do the following:
& gt; & Gt; Y = {'d' 'F' 'A' 'G' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' H '& gt; & Gt; Y (to find (diff (char (y)) == 0) + [0 1]) = [] y = '' f '' a '' w '' a '' h '
Comments
Post a Comment