构造并调用函数,保错提示 ERROR: syntax: expected “(” in function definition
技术分享
发布于 2025-10-16 19:55:47
查看 3过去229天
问题现象
构造并调用函数,保错提示 ERROR: syntax: expected “(” in function definition
function [text3] = testfunc(text1,text2)
text3 = text1 + text2
text4 = text3 + text2
end
testfunc(1,2)

解决方法
Matlab 中函数定义,[ ]内的作为返回值,Julia 没有这个用法,Julia 中函数返回可用 return。
function testfunc(text1,text2)
text3 = text1 + text2
text4 = text3 + text2
return text3
end
testfunc(1,2)

所属专栏:Syslab基础平台
产品信息:Syslab科学计算环境