<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi elisa</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">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.</p>
<p style="margin-top:0;margin-bottom:0"><img size="5743" contenttype="image/png" id="img745842" crossorigin="anonymous" tabindex="0" style="max-width: 99.9%; user-select: none;" src="cid:ec28adef-8cbc-4f0a-9b64-5e7b386b2d6f"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">you have to write </p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">"mFileErrorCode=0</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">return</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">"</span></p>
<p style="margin-top:0;margin-bottom:0">also at the end of some particular  "if statment" like:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">if trnInfo(8)==-1</p>
<p style="margin-top:0;margin-bottom:0">...</p>
<p style="margin-top:0;margin-bottom:0">...</p>
<p style="margin-top:0;margin-bottom:0">...</p>
<p style="margin-top:0;margin-bottom:0"></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
mFileErrorCode=0</p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
return</p>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Da:</b> 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</font>
<div> </div>
</div>
<div lang="IT">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi TRNSYS users,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">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>”.</p>
<p class="x_MsoNormal">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.
</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Someone of you has already dealt with this issue?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Kind regards,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Elisa Ghirardi</p>
<p class="x_MsoNormal">University of Bergamo, Italy.</p>
</div>
</div>
</div>
</div>
</body>
</html>