When I understand you correctly, you have a matrix as a variable in the command window and want to get the corresponding code.
function MatrixToClipboard(X, F)
Fmt = '%g';
[s1, s2] = size(X);
Xt = transpose(X);
FmtV = [repmat([Fmt, ', '], 1, s2 - 1), Fmt];
S = ['[', sprintf([FmtV, '; ...\n'], Xt(:, 1:s1 - 1)), ...
sprintf([FmtV, '];\n'], Xt(:, s1))];
Now call this from the command window:
X = rand(4, 5);
Finally press Strg-V in the editor to get:
[0.814724, 0.126987, 0.632359; ...
0.905792, 0.913376, 0.0975404];