- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Matlab 指针 pointer 的 使用说明
文章来源:不详 作者:佚名
--------------------------------------------------------------------------------
该文章讲述了Matlab 指针 pointer 的 使用说明.
指针是一种比较难以驾驭的工具。像是老郭这样的编程菜鸟使用指针,稍有不慎轻则内存泄漏,重则直接蓝屏,真是杯具。还好老郭喜欢的Java语言一开始就杜绝了指针的使用。Matlab也杜绝了指针,所以大家在网上只能搜到零零星星的介绍。
有一些万不得已非要使用指针的情况,譬如变长数组:老郭有100个矩阵,要分别求他们的奇异值分解,但是这100个矩阵大小不一样,怎么样编写循环呢?这就要用指针了。注意matlab拒绝将指针跟双精度数字混为一谈,所以如果用a来存储这100个矩阵,就要事先清空a,命令是
clear a
接下来,写循环命令储存矩阵:
a(i)=libpointer(doublePtrPtr,rand(6));
循环的那些for神马的,此处略去。这里doublePtrPtr是数据格式,double就是double,一维数组用doublePtr,三维用doublePtrPtrPtr,以此类推。rand(6)是矩阵,下一个循环单位可以写rand(4)都可以。这是储存的步骤,读取的步骤是:
get(a(2),Value)
就返回我们刚才存进去的第2个矩阵。Value是浮云,放在那里,不解释。
值得注意的是Matlab的这个机制本来是设计用于跟C等等语言做交互的。我们这里滥用一下。如果您想了解更多,查阅Matlab手册就行。
在Matlab中使用指针
个人日记 2010-10-22 17:39:15 阅读242 评论0 字号:大中小
The libpointer ObjectIn most cases, you can pass arguments to an external function by value, even when the prototype for that function declares the argument to be a pointer. The calllib function uses the header file to determine how to pass the function arguments.There are times, however, when it is useful to pass MATLAB arguments by reference, similar to using a C pointer:You want to modify the data in the input arguments.
You are passing large amounts of data, and you dont want to make copies of the data.
The library stores and uses the pointer for a period of time so you want the MATLAB function to control the lifetime of the libpointer object.In these cases, you use the libpointer function to construct a libpointer object of a specified type. A libpointer is an instance of a MATLAB lib.pointer class. The properties of this class are Value and DataType. The methods are:Methods for class lib.pointer: disp plus setdatatype isNull reshapeFor information about using the setdatatype method, see Reading Function Return Values. For an example using the plus operator, see Creating a Pointer by Offsetting from an Exist
您可能关注的文档
最近下载
- 家庭与社区的变化与发展.pptx VIP
- 丙肝防治培训课件.pptx VIP
- 《食物链》.ppt VIP
- 2025年辽宁丹东市融媒体中心招聘6人笔试模拟试题参考答案详解.docx VIP
- 2018湖北省市政工程定额(第十一册措施项目)PDF版.pdf VIP
- 4.1和面、揉面、饧面、搓条(课件)- 《中式面点制作基础教程》同步教学(劳保版).pptx VIP
- 2025年丹东市融媒体中心招聘考试笔试试题.docx VIP
- 铁路技术管理规程(普速铁路部分)题库 .pdf VIP
- 中国失眠症诊断和治疗指南(精选PPT).pptx VIP
- 2025年马鞍山市公安局第三季度招聘警务辅助人员139名笔试参考题库附答案解析.docx VIP
文档评论(0)