matlab 出现Undefined function 'functionname' for input arguments of type 'logical'问题的解决办法

这个问题纠结了好久应该有十二个小时。

尝试了好多解决办法都不行,最后慢慢试错,终于修正了这个问题。


我在谷歌上搜这个问题的时候,发现有一个国际友人的问题和我一毛一样

他是这么说的:


I'm getting the following error when I try to run some function m-files: ??? Undefined function or method '[name of function]' for input arguments of type 'double'.

I know this usually happens when the file isn't in the working directory, but that's not the case here.

When I was running these m-files in a different directory on my computer, it worked fine. I moved them to another directory on my laptop, and they're still fine, but I get this error on two of my desktops.


大体意思就是,在其他文件夹里面可以正常工作的这个函数,换到另一个文件夹的另一个调用环境就不好使了。但是将这个函数文件移动到其他文件夹里,又好使了。


我开始满心欢喜地以为这个问题已经被解决了,实则不然,还是没解决。


不卖关子了,这是什么问题呢。


其实很简单,就是cd这个命令惹的祸。


我在主函数里面


有这样一个 cd 进入其他文件夹的操作,然后并没有在使用 cd.. 命令返回上一级,导致在放置图片文件夹里面调用函数(当然放置图片的文件夹并没有任何函数),进而导致matlab报错。所以这可以看出,有一个好的编程思维和习惯是多么的重要。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值