专栏
标签
构造并调用函数,保错提示 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)

image.png

解决方法

Matlab 中函数定义,[ ]内的作为返回值,Julia 没有这个用法,Julia 中函数返回可用 return。

function testfunc(text1,text2)
    text3 = text1 + text2
    text4 = text3 + text2
    return text3
end

testfunc(1,2)

image.png

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

全部回答

暂无数据
暂无数据
用户
和原帖交流更多问题细节吧,去
我要发帖 我要发帖
资料中心 资料中心
查看更多>
热门帖子 热门帖子
主要贡献者 主要贡献者
过去7天