matlab 求代数方程组 a*x^2+b*x+c=0 x+y=0 关于x,y的解,并分别绘制x和y关于b和c的图像(a视作常数)

 我来答
宇逸ycl
2013-12-22 · TA获得超过4088个赞
知道大有可为答主
回答量:1589
采纳率:50%
帮助的人:1816万
展开全部

1. 求代数方程组的解:

>> [x,y]=solve('a*x^2+b*x+c=0','x+y=0','x,y')

 

x =

  1/2/a*(-b+(b^2-4*a*c)^(1/2))

 1/2/a*(-b-(b^2-4*a*c)^(1/2))


 y =

  -1/2/a*(-b+(b^2-4*a*c)^(1/2))

 -1/2/a*(-b-(b^2-4*a*c)^(1/2))

 >> 

2. 从上面的解可以看出,x,y都有两组解且x,y互为相反数。

假设a=1,这里有两种方法绘制x,y关于b,c的图像:

(1)隐函数绘图

x1=subs(x(1),'a',1);

x2=subs(x(2),'a',1);

y1=subs(y(1),'a',1);

y2=subs(y(2),'a',1);

figure

po=get(gcf,'position');

set(gcf,'position',[po(1)-0.5*po(3) po(2) 2*po(3) po(4)]);

subplot(121)

ezsurf(x1,[-10 10])

hold on

ezsurf(x2,[-10 10])

subplot(122)

ezsurf(y1,[-10 10])

hold on

ezsurf(y2,[-10 10])


(2)根据方程式直接绘图

>> a=1;

>> [b,c]=meshgrid(-10:0.5:10);

>> delta=b.^2-4*a*c;

>> delta(delta<0)=NaN;

>> x1=0.5/a*(-b+sqrt(delta));

>> x2=0.5/a*(-b-sqrt(delta));

>> y1=-x1;

>> y2=-x2;

>> figure

>> po=get(gcf,'position');

>> set(gcf,'position',[po(1)-0.5*po(3) po(2) 2*po(3) po(4)]);

>> subplot(121)

>> surf(b,c,x1)

>> hold on

>> surf(b,c,x2)

>> xlabel('b');ylabel('c');zlabel('x')

>> subplot(122)

>> surf(b,c,y1)

>> hold on

>> surf(b,c,y2)

>> xlabel('b');ylabel('c');zlabel('y')

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式