Use fullfile.
a='c:\folder1\'% PC1
b='d:\folder2\'% PC2
c='folder3\'
P = fullfile(a, c)
Note that the MATLAB that MATLAB Answers uses to run code in answers is on Linux, so fullfile will add the appropriate
filesep
between the two parts of the path. If you ran this on Windows the / character would not be present in P.