matlab求解积分并画图的问题.clear all syms xM=2;fx=exp(-x*x/2)/sqrt(2*pi);sn=-20:1:100;Q=int(fx,x,sn,inf);P=2*(M-1)*Q/M;plot(sn,P);运行之后出现 Error using ==> plotConversion to double from sym is not possible.Error in ==> Untitled at

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/27 22:28:51
matlab求解积分并画图的问题.clear all syms xM=2;fx=exp(-x*x/2)/sqrt(2*pi);sn=-20:1:100;Q=int(fx,x,sn,inf);P=2*(M-1)*Q/M;plot(sn,P);运行之后出现 Error using ==> plotConversion to double from sym is not possible.Error in ==> Untitled at

matlab求解积分并画图的问题.clear all syms xM=2;fx=exp(-x*x/2)/sqrt(2*pi);sn=-20:1:100;Q=int(fx,x,sn,inf);P=2*(M-1)*Q/M;plot(sn,P);运行之后出现 Error using ==> plotConversion to double from sym is not possible.Error in ==> Untitled at
matlab求解积分并画图的问题.
clear all
syms x
M=2;
fx=exp(-x*x/2)/sqrt(2*pi);
sn=-20:1:100;
Q=int(fx,x,sn,inf);
P=2*(M-1)*Q/M;
plot(sn,P);
运行之后出现
Error using ==> plot
Conversion to double from sym is not possible.
Error in ==> Untitled at 8
plot(sn,P);

matlab求解积分并画图的问题.clear all syms xM=2;fx=exp(-x*x/2)/sqrt(2*pi);sn=-20:1:100;Q=int(fx,x,sn,inf);P=2*(M-1)*Q/M;plot(sn,P);运行之后出现 Error using ==> plotConversion to double from sym is not possible.Error in ==> Untitled at
提示你从符号变量变到双精度数值出现错误.还有你注意有些地方需要用到点乘或点除.给你一个可以运行的程序:
clear all;
syms x;
M=2;
fx=exp(-x*x/2)/sqrt(2*pi);
sn=-20:1:100;
t=length(sn);
Q0=zeros(length(sn));
Q=Q0(1:length(sn));
for k=1:t
Q(k)=eval(int(fx,x,sn(k),inf));
end
P=2*(M-1)*Q/M;
plot(sn,P);