求问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')
这样做为什么不行啊,大神应该怎么写啊。 展开
已知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')
这样做为什么不行啊,大神应该怎么写啊。 展开
1个回答
展开全部
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.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询