setdiff error in some cases
    4 views (last 30 days)
  
       Show older comments
    
Hi I am using setdiff in my code and i am getting 'Improper assignment with rectangular empty matrix' error in a particular case , why and how to solve this? my code is as below:
 A = dataset();
 A.Location = {'south'};
 A.Number = 3;
 B= dataset();
 B.Location = {'north'};
 B.Number = 3;
 diff1 = setdiff(A, B); %THIS EXECUTES JUST FINE
 C= dataset();
 C.Location = {'north'};
 C.Number = 3;
 C(1, :) = [];
 D= dataset();
 D.Location = {'west'};
 D.Number = 5;
 D.Location(2, 1) = {'north'};
 diff2 = setdiff(C, D); %THIS EXECUTES JUST FINE
 diff3 = setdiff(C, B); %THIS GIVES ME ERROR MENTIONED ABOVE, WHY?
5 Comments
  dpb
      
      
 on 1 Oct 2014
				...What is TMW?...
The Mathworks, vendors of Matlab. Shorthand for the suggestion you contact official support at www.mathworks.com with a support request for an official interpretation of the behavior observed if you think it's important that the null input case not fail.
Accepted Answer
  Peter Perkins
    
 on 2 Oct 2014
        Neesha, this appears to be a bug when one of the datasets has zero rows and the other has exactly one. A valid edge case to be sure, but somewhat obscure. I will make a note to adress this bug.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



