matlab向函数数组传递数组吗?function y=zhengtai(x)y=1/sqrt(2*pi)*exp(-x^2/2);end %函数定义 %命令x=-3:0.1:3;y=zhengtai(x)结果是? Error using ==> mpowerInputs must be a scalar and a square matrix.Error in ==>

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 13:09:45
matlab向函数数组传递数组吗?functiony=zhengtai(x)y=1/sqrt(2*pi)*exp(-x^2/2);end%函数定义%命令x=-3:0.1:3;y=zhengtai(x)

matlab向函数数组传递数组吗?function y=zhengtai(x)y=1/sqrt(2*pi)*exp(-x^2/2);end %函数定义 %命令x=-3:0.1:3;y=zhengtai(x)结果是? Error using ==> mpowerInputs must be a scalar and a square matrix.Error in ==>
matlab向函数数组传递数组吗?
function y=zhengtai(x)
y=1/sqrt(2*pi)*exp(-x^2/2);
end %函数定义
%命令
x=-3:0.1:3;
y=zhengtai(x)
结果是
? Error using ==> mpower
Inputs must be a scalar and a square matrix.
Error in ==> zhengtai at 2
y=1/sqrt(2*pi)*exp(-x^2/2);
这是怎么回事呢?

matlab向函数数组传递数组吗?function y=zhengtai(x)y=1/sqrt(2*pi)*exp(-x^2/2);end %函数定义 %命令x=-3:0.1:3;y=zhengtai(x)结果是? Error using ==> mpowerInputs must be a scalar and a square matrix.Error in ==>
因为x是矩阵,所以需要点乘
y=1/sqrt(2*pi)*exp(-x.^2/2);
你再试下