def put_variables(self, mdict, write_header=None):
<EOL>if write_header is None:<EOL><INDENT>write_header = self.file_stream.tell() == <NUM_LIT:0><EOL><DEDENT>if write_header:<EOL><INDENT>self.write_file_header()<EOL><DEDENT>self._matrix_writer = VarWriter5(self)<EOL>for name, var in mdict.items():<EOL><INDENT>if name[<NUM_LIT:0>] == '<STR_LIT:_>':<EOL><INDENT>continue<EOL><DEDENT>is_global = name in self.global_vars<EOL>if self.do_compression:<EOL><INDENT>stream = BytesIO()<EOL>self._matrix_writer.file_stream = stream<EOL>self._matrix_writer.write_top(var, asbytes(name), is_global)<EOL>out_str = zlib.compress(stream.getvalue())<EOL>tag = np.empty((), NDT_TAG_FULL)<EOL>tag['<STR_LIT>'] = miCOMPRESSED<EOL>tag['<STR_LIT>'] = len(out_str)<EOL>self.file_stream.write(tag.tostring())<EOL>self.file_stream.write(out_str)<EOL><DEDENT>else:  <EOL><INDENT>self._matrix_writer.write_top(var, asbytes(name), is_global)<EOL><DEDENT><DEDENT>
Write variables in `mdict` to stream

        Parameters
        ----------
        mdict : mapping
           mapping with method ``items`` returns name, contents pairs where
           ``name`` which will appear in the matlab workspace in file load, and
           ``contents`` is something writeable to a matlab file, such as a numpy
           array.
        write_header : {None, True, False}
           If True, then write the matlab file header before writing the
           variables.  If None (the default) then write the file header
           if we are at position 0 in the stream.  By setting False
           here, and setting the stream position to the end of the file,
           you can append variables to a matlab file