Why do I get a “Too many input arguments” error when passing in proper parameters?

限于喜欢 提交于 2019-12-01 11:26:58

Unless you intend ensureCellType to be a Static method (in which case you should declare it with (Static=true), you should give it the signature cellData = ensureCellType(obj,value). obj gives you a reference to the object itself within the method.

You're getting the error you see because MATLAB is passing in both the object itself and value into your method, which is two input arguments rather than one.

If you will never need a reference to obj within the method, you can declare the method signature as cellData = ensureCellType(~, value). Then MATLAB will know that it should have two inputs, but it can ignore passing in the first.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!