關於C++與Matlab混合編程錯誤??? Unexpected Standard exception from MEX file.

來源:互聯網
上載者:User

標籤:matlab   記憶體配置   c++   exception   



最近在用c++和matlab 混合編程是遇到了一些問題,如下:

??? Unexpected Standard exception from MEX file.
What() is:c:program


Error in ==> mscale at 32
   [rho,s] = matscale(abs(a),0.01);

Error in ==> utScaledExpm at 7
[s,junk,a] = mscale(a,‘noperm‘,‘safebal‘);

Error in ==> ssdata.utDiscretizeZOH at 171
      s = utScaledExpm([[a b]*Ts; zeros(nu,nx+nu)]);

Error in ==> ssdata.trespSetUp at 104
            [D,XMap] = utDiscretizeZOH(D,dt,XMap);

Error in ==> ltidata.timeresp at 78
   [Dsim,dt,tf,SimInfo] =
   trespSetUp(D,RespType,dt,tf,x0);

Error in ==> lti.step at 67
      [y,t,focus] = timeresp(D,‘step‘,t);

Error in ==> step at 125
   yout = step(sys,t);

關於異常,請參加:http://www.cplusplus.com/reference/exception/exception/


1. 直接在網上的程式或者直接用的別人的code,會由於配置以及環境問題導致問題,此處並不一定拋出異常,比較容易尋找;
2. 程式當時的Matlab版本不同與自己目前的Matlab版本不同,有導致拋出異常的可能性,並且自己也有經曆;

3.有時候,如果用C++的容器(list、vector等),如果size 或者迭代器使用不當也會導致越界訪問異常,特別是對於容器的邊界,尤其注意,本人曾在這裡不止吃了一次苦頭!
4. 因為記憶體配置與釋放問題,在程式運行幾次後,你的CPU佔用率很高的話,就應該考慮此原因,是不是忘記release resource了!
尋找錯誤的關鍵在於跟蹤與定位,切記哦!










關於C++與Matlab混合編程錯誤??? Unexpected Standard exception from MEX file.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.