求问matlab大神如何求解参数方程的参数值

举个简单的例子,y=a*x^2+b*x已知y(2)-y(1)=0y(3)+y(4)=5求出a,b的值。symsabxyf1f2;y=a*x^2+b*x;f1=subs(y... 举个简单的例子,y=a*x^2+b*x
已知y(2)-y(1)=0
y(3)+y(4)=5
求出a,b的值。

syms a b x y f1 f2;
y=a*x^2+b*x;
f1=subs(y,x,1)-subs(y,x,0);
f2=subs(y,x,3)+subs(y,x,4);
[a,b]=solve('f1=0','f2=5','a','b')

这样做为什么不行啊,大神应该怎么写啊。
展开
 我来答
Miafifi
2015-06-18 · TA获得超过451个赞
知道小有建树答主
回答量:277
采纳率:93%
帮助的人:166万
展开全部

Hi, I have tested your code. It seems you have almost done most of work but neglect a tiny error inside.

Also I would like to mention that the incorrect documentation 2014a may be a trick for you to successfully debug your error.

For example:

syms u v
[sv,su] = solve([2*u^2+v^2 == 0, u-v == 1], [v,u]) % Doesn't work

Just be wary of it. Here is my solution for solvin multivariate equations followed by:

clear all

syms a b x y f1 f2;

y = a*x^2+b*x;

f1 = subs(y,x,2)-subs(y,x,1);
f2 = subs(y,x,3)+subs(y,x,4);

[sa,sb] = solve([f1 == 0, f2 == 5], a, b);

fprintf('a = %s\n',char(sa))
fprintf('b = %s\n',char(sb))

The output should be

If you like my reply, please give me thumb UP.

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

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式