Sorry I forgot to delete two lines in the code example above - this is the correct code example:
%% set geometry up and solve
model = createpde('thermal','steadystate');
R1=[3 4 0 1 1 0 0 0 1 1]';
R2=[3 4 0.5 1 1 0.5 0.5 0.5 1 1]';
gm=[R1,R2];
sf='R1+R2';
ns=char('R1','R2')
ns=ns';
g=decsg(gm,sf,ns);
figure(1)
pdegplot(g,'FaceLabels','on','EdgeLabels','on')
%% create mesh
geometryFromEdges(model,g)
generateMesh(model,'Hmax',0.025);
figure(2)
pdemesh(model);
%% set boundary conditions
thermalBC(model,'Edge',[1],'Temperature',0);
thermalBC(model,'Edge',[7:8],'Temperature',1);
thermalBC(model,'Edge',[2],'HeatFlux',0);
thermalBC(model,'Edge',[5:6],'HeatFlux',0);
%% set thermal parameter
k1=@(location,~) 1*location.x;
k2=@(location,~) 20*location.x;
thermalProperties(model,'Face',2,'ThermalConductivity',k1);
thermalProperties(model,'Face',1,'ThermalConductivity',k2);
%% solve model
result = solve(model);
temp = result.Temperature;
figure(3)
pdeplot(model,'XYData',temp,'Contour','on');
set(gca,'box','on')