matlab程序,麻烦帮我看下哪里有错以及怎么改%画等势线及电场线function f=draw(s)a=-2:0.1:2;b=a';a=ones(size(b))*a;b=b*ones(size(b))';z=subs(s,{x,y},{a,b});[dx,dy]=grandient(z);xx=[linspace(-2,2,10),2*linspace(1,1,10),linspace(-2,
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 04:22:25
matlab程序,麻烦帮我看下哪里有错以及怎么改%画等势线及电场线function f=draw(s)a=-2:0.1:2;b=a';a=ones(size(b))*a;b=b*ones(size(b))';z=subs(s,{x,y},{a,b});[dx,dy]=grandient(z);xx=[linspace(-2,2,10),2*linspace(1,1,10),linspace(-2,
matlab程序,麻烦帮我看下哪里有错以及怎么改
%画等势线及电场线
function f=draw(s)
a=-2:0.1:2;
b=a';
a=ones(size(b))*a;
b=b*ones(size(b))';
z=subs(s,{x,y},{a,b});
[dx,dy]=grandient(z);
xx=[linspace(-2,2,10),2*linspace(1,1,10),linspace(-2,2,10),-2*linspace(1,1,10),0.01*linspace(1,1,10),-0.01*linspace(1,1,10)];
yy=[2*linspace(1,1,10),linspace(-2,2,10),-2*linspace(1,1,10),linspace(-2,2,10),linspace(-2,2,10),linspace(-2,2,10)];
contour(a,b,z,[-12,-8,-5,-3,-1,-0.5,-0.1,0.1,0.5,1,3,5,8,12])
hold on
streamline(a,b,dx,dy,xx,yy)
s一个是符号表达式
matlab程序,麻烦帮我看下哪里有错以及怎么改%画等势线及电场线function f=draw(s)a=-2:0.1:2;b=a';a=ones(size(b))*a;b=b*ones(size(b))';z=subs(s,{x,y},{a,b});[dx,dy]=grandient(z);xx=[linspace(-2,2,10),2*linspace(1,1,10),linspace(-2,
M文件里要定义x,y
subs()里要用[]号吧
grandient()写错了吧,应该是gradient()……