在matlab中,Function definitions are not permitted at the prompt or in scripts是什么错误?function z=f2(t,s)z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]f2(3,4)

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 08:10:32
在matlab中,Function definitions are not permitted at the prompt or in scripts是什么错误?function z=f2(t,s)z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]f2(3,4)

在matlab中,Function definitions are not permitted at the prompt or in scripts是什么错误?function z=f2(t,s)z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]f2(3,4)
在matlab中,Function definitions are not permitted at the prompt or in scripts是什么错误?
function z=f2(t,s)
z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]
f2(3,4)

在matlab中,Function definitions are not permitted at the prompt or in scripts是什么错误?function z=f2(t,s)z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]f2(3,4)
你的命令是要自己定义一个f2函数,不能直接在命令窗口和直接新建的m文件(脚本文件script)中运行.你要将这个函数命令保存为一M函数文件,即将
function z=f2(t,s)
z=[exp(-t+s),exp(-t+3*s)+exp(-2*t+4*s);0,exp(-4*t+4*s)]
保存为f2.m(文件名与函数铭一致),然后再命令窗口输入f2(3,4),敲回车就可以运行出结果.
你需要弄清楚脚本文件和M函数文件的区别. 希望对你有帮助!