Looks like this can be done, someone posted an answer on MathWorks using a similar term of "null file". Not sure if that's valid terminology but could be a shortening of "null device file".
The way to reference the null device is OS dependent...
nullFID = fopen( 'NUL:' ); % Windows
nullFID = fopen('/dev/null'); % UNIX
And it also appears the reference varies from Matlab releases. Consider the following script
ver
nullFID = fopen( 'NUL:' , 'w' )
fprintf( nullFID , '12345' )
nullFID = fopen( 'NUL:' )
fprintf( nullFID , '12345' )
nullFID = fopen('NUL' , 'w' )
nullFID = fopen('NUL' )
And the following output generated from two versions of Matlab...
R2011b
>> ver
-------------------------------------------------------------------------------------
MATLAB Version 7.13.0.564 (R2011b)
MATLAB License Number: xxxx
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------
MATLAB Version 7.13 (R2011b)
>> nullFID = fopen( 'NUL:' , 'w' )
nullFID = 119
>> fprintf( nullFID , '12345' )
ans = 5
>> nullFID = fopen( 'NUL:' )
nullFID = 120
>> fprintf( nullFID , '12345' )
ans = 0
>> nullFID = fopen('NUL' , 'w' )
Warning: You have chosen a reserved DOS device name for your filename.
Please choose another valid filename
nullFID = -1
>> nullFID = fopen('NUL')
nullFID = -1
R2015a
>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.5.0.197613 (R2015a)
MATLAB License Number: 1093113
Operating System: Microsoft Windows 7 Professional Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.5 (R2015a)
>> nullFID = fopen( 'NUL:' , 'w' )
nullFID = -1
>> fprintf( nullFID , '12345' )
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
>> nullFID = fopen( 'NUL:' )
nullFID = 8
>> fprintf( nullFID , '12345' )
ans = 0
>> nullFID = fopen('NUL' , 'w' )
Warning: You have chosen a reserved DOS device name for your filename.
Please choose another valid filename.
nullFID = -1
>> nullFID = fopen('NUL' )
nullFID = -1
w
in one case and not in the other? You should also mention the first is for windows, the second for linux. – Caw