Use the whos function:
varinfo=whos('data');
saveopt='';
if varinfo.bytes >= 2^31
saveopt='-v7.3';
end
save('filename','data',saveopt);
This code is a bit too conservative in that it will use -v7.3 format when data is over 2gb but only needs to when a member of data is over 2gb. I do not see that as a problem and checking all members is a bit more work.
That said I would not do this. I would use the -v7.3 option for all files. Some day in the future it may complicate things to have files that are of different formats.