Your x1 is the same size as t1, and your x2 is the same size as t2. x1+x2 is therefore attempting to add a vector of length 20000 and a vector of length 25000.
You are using the wrong approach.
f1 = 4000;
A1 = 0.2;
f2 = 5000;
A2 = 0.25;
secs = 5;
N = lcm(f1*secs, f2*secs);
t = linspace(0, secs, N+1);
t(end) = ;
x1 = A1*cos(2*pi*f1*t)+randn(size(t));
x2 = A2*cos(2*pi*f2*t)+randn(size(t));
You should consider whether the randn should be at full magnitude or should be multiplied by A1 or A2 . As it is you have 5 times as much noise as you have signal for x1.
You do not really need the full lcm() samples over 5 seconds, but using the lcm() ensures that there are an exact integer number of cycles for each of f1 and f2 in those 5 seconds.
I am, though, seeing some clipping in cos(2*pi*f1*t) that I cannot quite explain at the moment.