Difference between two cell arrays

93 views (last 30 days)
I have two cell arrays one is of 12*21cell and thw other is of 1*21 cell.I when i take their difference matlab gives me then 11*1cell rather it should give me 11*21cell. Can anybody tell me why is it so and whats the solution to this?
this is my code:
>>clear all
>>for i=1:21
>>ImgPath = dir(strcat('F:\FLD\FLD_based Face Recognition System_v2',a,'\*.jpg'));%path of folder containing images
>>for k=1:length(ImgPath)
> fileNames = ImgPath(k).name;
> %S=imread(strcat('F:\FLD\FLD_based Face Recognition System_v2',a,'\',int2str(k),'.jpg'));
> I{k,i}=fileNames;
>>for j=1:length(I)

Accepted Answer

Walter Roberson
Walter Roberson on 10 May 2017
You are creating cell arrays of strings. setdiff() applied to cell arrays of strings tells you all of the strings that are present in the first parameter but not present in the second parameter. setdiff(A,B) for cell arrays of strings is like
result = A; %start with the first
result( ismember(A, B) ) = []; %remove everything present in the second
setdiff() is for set membership.
setdiff() has nothing to do with telling you whether one set of named files is somehow similar to a different set of named files.
Walter Roberson
Walter Roberson on 10 May 2017
No, I cannot tell you how to solve that. Your expectation of what setdiff does appears to be incorrect.

Sign in to comment.

More Answers (0)


Find more on Performance and Memory in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by