<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
        {mso-style-name:x_msonormal;
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=IT link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-GB>thanks Riccardo for your reply and your help. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Unfortunately I have already set all the mFileErrorCode like your suggestion but I still have the same error.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>It would be an issue with a too recent version of Matlab? (I’m using a 64-bit version of Trnsys 18 (18.00.0016) with a 64-bit version of Matlab 2016a)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Elisa Ghirardi</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>Da: </b><a href="mailto:trnsys-users@lists.onebuilding.org">Riccardo Nesa via TRNSYS-users</a><br><b>Inviato: </b>lunedì 22 gennaio 2018 12:13<br><b>A: </b><a href="mailto:trnsys-users@lists.onebuilding.org">TRNSYS users mailing list at OneBuilding.org</a><br><b>Cc: </b><a href="mailto:riccardo_sas@hotmail.it">Riccardo Nesa</a><br><b>Oggetto: </b>Re: [TRNSYS-users] type 155 and GenOpt</p></div><p class=MsoNormal><o:p> </o:p></p><p><span style='font-size:12.0pt;color:black'>Hi elisa<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'>you have to put "mFileErrorCode=some_number" in the m.file to get the point when your script fails and you MUST write "mFileErrorCode=0" at the end of the m.file.<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><img border=0 width=794 height=111 style='width:8.2708in;height:1.1562in' id=img745842 src="cid:ec28adef-8cbc-4f0a-9b64-5e7b386b2d6f" alt="cid:ec28adef-8cbc-4f0a-9b64-5e7b386b2d6f"></span><span style='font-size:12.0pt;color:black'><o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'>you have to write <o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'>"mFileErrorCode=0<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>return<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>"<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>also at the end of some particular  "if statment" like:<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'>if trnInfo(8)==-1<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>...<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>...<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>...<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>mFileErrorCode=0<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'>return<o:p></o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='font-size:12.0pt;color:black'><img border=0 width=694 height=2 style='width:7.2291in;height:.0208in' id="Horizontal_x0020_Line_x0020_2" src="cid:image002.png@01D3938E.507A2E60"></span><span style='font-size:12.0pt;color:black'><o:p></o:p></span></p><div id=divRplyFwdMsg><p class=MsoNormal><b><span style='color:black'>Da:</span></b><span style='color:black'> TRNSYS-users <trnsys-users-bounces@lists.onebuilding.org> per conto di Elisa Ghirardi via TRNSYS-users <trnsys-users@lists.onebuilding.org><br><b>Inviato:</b> lunedì 22 gennaio 2018 09:30<br><b>A:</b> trnsys-users@lists.onebuilding.org<br><b>Cc:</b> Elisa Ghirardi<br><b>Oggetto:</b> [TRNSYS-users] type 155 and GenOpt</span><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p><div><p class=MsoNormal><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p></div></div><div><div><p class=xmsonormal><span style='font-size:12.0pt;color:black'>Hi TRNSYS users,<o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'>I’m trying to run an optimization with TrnOpt with a link with matlab (type 155). The single simulation works, but when I run the optimization I have always the same error: “<i>The M-File did not properly set 'mFileErrorCode' to 0 when it was called. This may indicate that an error occurred in Matlab while running the M-File. 'mFileErrorCode' was left to 1 by the M-File. You can set ignoreEngineClose to 1 and run the 'lasterr' command in Matlab to help diagnose the  problem. The error occurred at info(7) =            0 , info(13) =            0</i>”.<o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'>I think it’s a problem  with matlab file access because , despite the .m file being inserted into the GenOpt input file, the GenOpt seems unable to start it, in fact GenOpt starts matlab but then fails to open the file. <o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'>Someone of you has already dealt with this issue?<o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'>Kind regards,<o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'> <o:p></o:p></span></p><p class=xmsonormal><span style='font-size:12.0pt;color:black'>Elisa Ghirardi<o:p></o:p></span></p></div></div></div><p class=xmsonormal><span style='font-size:12.0pt;color:black'>University of Bergamo, Italy.<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>