matlab c++ 画图

最近有朋友问我他照着我之前的一篇文章(http://blog.csdn.net/owldestiny/archive/2009/03/07/3966340.aspx )

做画图的时候画不出来图像,不知道如何解决,自己试了一下,搞定了在这里贴出来

首先matlab文件他是这样写的:

C++代码是:

C++代码最后一句建议加上system("pause");

这样如果程序运行过快最后还是能停下等待按键,就可以看到程序运行的结果;

加上之后控制台中报错为:

testWarning: 1 visible figure(s) exist at MCR termination.
If your application has terminated unexpectedly, please note that
 applications generated by the MATLAB Compiler terminate when there are no
 visible figure windows. See the documentation for WaitForFiguresToDie and
 WAITFORCALLBACKS for more information.
Warning: Class
    'graph2d.lineseries'
in use at MCR termination.
If your application has terminated unexpectedly, please note that
 applications generated by the MATLAB Compiler terminate when there are no
 visible figure windows. See the documentation for WaitForFiguresToDie and
 WAITFORCALLBACKS for more information.
Warning: Objects of graph2d.lineseries class exist - not clearing this class
or any of its super-classes

大致的意思就是图片在退出MCR时仍然存在,这个是不允许的,terminate时MCR就不存在了,图片也不可能继续显示,

解决的方法是将MCR存在的时间延长,可以在Matlab代码中加入延时程序或等待按键代码,我采用的是等待按键,

最后一行就是等待鼠标按键,w变为0,循环终止,draw函数终止,MCR退出;

 

C++的代码也进行了一点修改,

这样就可以实现了,具体代码在这里(http://download.csdn.net/source/1341025 )可以下载到,,欢迎大家与我讨论,mailto:chen0510566@163.com

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值