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/06/30 16:45:40
![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 ==>](/uploads/image/z/3166815-39-5.jpg?t=matlab%E5%90%91%E5%87%BD%E6%95%B0%E6%95%B0%E7%BB%84%E4%BC%A0%E9%80%92%E6%95%B0%E7%BB%84%E5%90%97%3Ffunction+y%3Dzhengtai%28x%29y%3D1%2Fsqrt%282%2Api%29%2Aexp%28-x%5E2%2F2%29%3Bend+++++++++++%25%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89+++++++++++++++++%25%E5%91%BD%E4%BB%A4x%3D-3%3A0.1%3A3%3By%3Dzhengtai%28x%29%E7%BB%93%E6%9E%9C%E6%98%AF%3F+Error+using+%3D%3D%3E+mpowerInputs+must+be+a+scalar+and+a+square+matrix.Error+in+%3D%3D%3E)
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);
你再试下