`

matlab使用笔记

阅读更多
最近开始使用matlab编程,在这里记录下使用过程中需要注意的问题。
1.matlab的函数参数是值传递,不同的函数之间使用不同的变量空间,嵌套函数也是一样。
2.??? Undefined function or method 'plus' for input arguments of type 'cell'.或??? Undefined function or method 'mtimes' for input arguments of type 'cell'.是因为将元胞数组进行了+或*运算,解决办法是用cell2mat( )处理参数,详细请google。
3.matlab使用HashMap数据结构。我用的是matlab R2010b,matlab好像是从R2008a(具体不详)开始支持使用java数据结构。代码如下
hashMap=java.util.HashMap;
for i=1:length(authors) %authors为元胞数组
    name=authors(i);%获得其中的第i项
    name=name{1};%将元胞数组的内容转为字符串
    hashMap.put(name,i);%放入HashMap中
end
经测试数字和字符串都可以当做key使用。
4.matlab字符串拼接,使用['welcome','to','matlab']。另外带数字的字符串拼接用num2str函数,例如['2 times is ', num2str(2),' times']
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics