作业帮 > 综合 > 作业

matlab中function和end问题,错误提示This statement is not inside any f

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/05 19:30:18
matlab中function和end问题,错误提示This statement is not inside any function.(6行代码)
function RC = reflect_coeff( ZL,Z0,f )
RC = 0.5*abs(ZL-Z0)/sqrt(ZL*Z0)*abs(cos(f*pi/2));
end
x=0:0.1:5;
a=reflect_coeff(100,50,x);
plot(x,a,'b-')
------------------------------------------------------------------------
>> micro_a
Error:File:micro_a.m Line:5 Column:1
This statement is not inside any function.
(It follows the END that terminates the definition of the function
"reflect_coeff".)
可以单独保存1-3行代码后在命令行中运行5-7行代码或改为
function reflect_coeff
x=0:0.1:5;
a=reflect_coeff1(100,50,x);
plot(x,a,'b-')
function RC = reflect_coeff1( ZL,Z0,f )
RC = 0.5*abs(ZL-Z0)/sqrt(ZL*Z0)*abs(cos(f*pi/2));