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/07/02 18:23:05
![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](/uploads/image/z/12520458-18-8.jpg?t=matlab%E6%B1%82%E8%A7%A3%E7%A7%AF%E5%88%86%E5%B9%B6%E7%94%BB%E5%9B%BE%E7%9A%84%E9%97%AE%E9%A2%98.clear+all+syms+xM%3D2%3Bfx%3Dexp%28-x%2Ax%2F2%29%2Fsqrt%282%2Api%29%3Bsn%3D-20%3A1%3A100%3BQ%3Dint%28fx%2Cx%2Csn%2Cinf%29%3BP%3D2%2A%28M-1%29%2AQ%2FM%3Bplot%28sn%2CP%29%3B%E8%BF%90%E8%A1%8C%E4%B9%8B%E5%90%8E%E5%87%BA%E7%8E%B0+Error+using+%3D%3D%3E+plotConversion+to+double+from+sym+is+not+possible.Error+in+%3D%3D%3E+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);