anova 3 way sum of square type - mtalb

I have written 3way-anova in c++. I have 3 factors, lets say a,b and c. The result of my code is the same as MATLAB when I use type I sum of squares.
But when I change the data so that the number of replicates is so high for a number of cells and too low for other cells: I don't get the same results as MATLAB. (to be precise, only SSt, SSe and SSa are the same as MATLAB)
My question is that is it possible that since I have a large difference in the number of replicates, I should use type III sum of squares? Or is there is special way that matlab treats the data in such cases so its results differs from mine?

Thanks for your help. Pegah
Last edited: