<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_mfile(mfile, outfile=None):
 """ Convert a Matlab m-file into a Matlab notebook in ipynb format Parameters mfile : string Full path to a matlab m file to convert outfile : string (optional) Full path to the output ipynb file """

    lines = mfile_to_lines(mfile)
    nb = lines_to_notebook(lines)
    if outfile is None:
        outfile = mfile.split('.m')[0] + '.ipynb'
    with open(outfile, 'w') as fid:
        nbwrite(nb, fid)