0

I need elements from the last cell (say k-th) not occurring in cell before it i.e. (k-1)th cell where k = 1,2,...,p. An example, k=2, r=2^(k+2)+2, n=2^(k)+1;

for i=1:k
    dt = 1:2^i:n;
     for j=1:2^(k-i)+1
       cd(j,:)= dt+ r*(j-1);
     end
   dd{i}=cd;
   clear cd
end        

dd{1} =[1 3 5; 11 13 15; 21 23 25]
dd{2} = [1 5;21 25]

I want all entries occurring in dd{2} removed from dd{1} i.e.

dd{1}= [3 11 13 15 23].
dd{2}= [1 5;21 25]

Kwesi
  • 1
  • 2
  • This does not seem to have anything to do with cell arrays. You want elements occuring in a list removed from some list? Also, you should finish writing the question before posting. It was completely unintelligible before your last edit. – oseiskar Feb 23 '13 at 10:17
  • @oseiskar; yes, i admit..the syntax for the code formatting made me commit that error (its my first time). To the question,i want elements recurring removed.I used cell-arrays because of dd having different sizes. nonetheless you're right. – Kwesi Feb 23 '13 at 10:27

1 Answers1

0

I think you can use setdiff to achieve your goal (difference of two arrays):

setdiff([1,2,3,4,5],[3,4])

ans =

     1     2     5
oseiskar
  • 3,282
  • 2
  • 22
  • 22
  • @oseikar, thanks..i know the 'setdiff' command.I didn't find it really helpful especially if k is large.this will mean comparing a lot of cells. – Kwesi Feb 23 '13 at 23:51