There's nothing in the documentation for writematrix that should have led you to think you could possibly do what you're asking with it.
It writes a matrix to a text or spreadsheet file but nothing is mentioned about having any header information or other than a homogenous matrix as an input and there are no optional named arguments that provide a naming facility nor, even, the ability to append to a file.
To do what you wish to do precisely, you would first open a file using fopen returning a file handle, write the formatted text with fprintf followed by writing the array. There you could possible use csvwrite with the append option. Then, "rinse and repeat" for the second array and close the file.
Alternatively, since your two arrays are commensurate in size, you could convert to a table and then use writetable which will identify variables in the table by column.
If the intent/need is to just have a way to save/recover a set of variables form the workspace and not to have text files for visual inspection and editing or some similar purpose, then the simplest way is to use the builtin Matlab storage facility of a .mat file --
save ab.mat a b
You can see whos in the .mat file with whos
>> whos -file xy.mat
Name Size Bytes Class Attributes
x2 10000x1 80000 double
y2 10000x1 80000 double
for an example just laying around here...