ebsd =[ebsd1 ebsd2];l = length(ebsd.phaseId);
% create matrix to replace the false ebsd.id
A = 1:l;
newId = reshape(A,[l,1]);
ebsd.id = newId;
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',segAngle,'unitCell');
Difficult to get a feel for what is causing the problem, have you tried breaking it down into parts?
What do you get if you do calcgrains for ebsd2 (i.e. get rid of joining issue)?
% region is a rectangle comprising the data to keep
condition = inpolygon(ebsd2,region);
Error using EBSD/set.grainId (line 139)The list of grainId has to have the same size as the list of ebsd data.
Error in dynProp/subsasgn (line 125) dp = builtin('subsasgn',dp,s,value);
Error in EBSD/subsasgn (line 43) ebsd = subsasgn@dynProp(ebsd,s,b);Or combine ebsd with itself using your joining method (i.e. get rid of issue with diff in step size)?
% find shifting parameters dx&dy by trial and error
max_ebsd1 = max(ebsd1.x);
ebsd2s = shift(ebsd2imp,[(max_ebsd1-dx), dy]);
% find scaling parameter sc by trial and error
ebsd2 = ebsd2s;
ebsd2.y = ebsd2s.y*sc;
ebsd2.unitCell = calcUnitCell([ebsd2.prop.x(:),ebsd2.prop.y(:)]);
% combine ebsd data
ebsd=[ebsd1 ebsd2];
% remove overlapping part of ebsd2
condition = ebsd2.x>max_ebsd1;
ebsd = [ebsd1 ebsd2(condition)];
% fix ebsd.id
l = length(ebsd.phaseId);
A = 1:l;
newId = reshape(A,[l,1]);
ebsd.id = newId;
% reconstruct grains
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',segAngle);