MATLAB: Is it possible to have output in an input format

i/oinputoutput

Eg, if you type
>> var1
in the command line, that it would output:
var1 = [1, 2, 3, 4];
instead of
ans = …
This could be usefull, to give output from one file to another by manually copy-pasting it ..
Thanks!

Best Answer

dm = @(M) fprintf('%s = %s\n', inputname(1), mat2str(M));
Then
dm(var1)