我想通过使用加号运算符(即 plus(a,b))在 MATLAB 中创建一个函数,当用户传递两个字符串时,它们将连接在一起并显示为结果。但是,每次我检查这个时,我都会收到无法实现内置函数的错误。是否可以在 MATLAB 中执行此操作,如果可以,执行此操作的程序是什么?
对这个问题的任何帮助表示赞赏。
最佳答案
@char
function c = plus(a,b)
c = horzcat(a,b); %// if you want the result to be output
disp(c) %// if you want the result to be displayed
@char
目录的父目录在 MATLAB 路径上(或者是当前目录)。 >> 'abc' + 'def'
abcdef
ans =
abcdef
关于MATLAB 重载加运算符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34553467/