Matlab错误求改.急syms x1 x2 x3 x4 x5;e=0.001;c=[5;4;3;2;1]Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];x=[x1;x2;x3;x4;x5]f=c'*x+0.5*x'*Q*xtidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]x1=0;x2=0;x3=0;x4=0;x5=0;flag=1;k=0;t

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 09:22:23
Matlab错误求改.急syms x1 x2 x3 x4 x5;e=0.001;c=[5;4;3;2;1]Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];x=[x1;x2;x3;x4;x5]f=c'*x+0.5*x'*Q*xtidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]x1=0;x2=0;x3=0;x4=0;x5=0;flag=1;k=0;t

Matlab错误求改.急syms x1 x2 x3 x4 x5;e=0.001;c=[5;4;3;2;1]Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];x=[x1;x2;x3;x4;x5]f=c'*x+0.5*x'*Q*xtidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]x1=0;x2=0;x3=0;x4=0;x5=0;flag=1;k=0;t
Matlab错误求改.急
syms x1 x2 x3 x4 x5;
e=0.001;
c=[5;4;3;2;1]
Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];
x=[x1;x2;x3;x4;x5]
f=c'*x+0.5*x'*Q*x
tidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]
x1=0;x2=0;x3=0;x4=0;x5=0;
flag=1;k=0;
tiduzhi=subs(tidu);
k=k+1;
t=0;
for(i=1:5)
t=t+tiduzhi(i)^2;
end
if (t>0)
flag=0;
xstar=subs(x)
end
报错?Function 'gt' is not defined for values of class 'sym'.
Error in ==> gt at 18
[varargout{1:nargout}] = builtin('gt',varargin{:});
明明我t算出来是数值呀.为啥不能比大小

Matlab错误求改.急syms x1 x2 x3 x4 x5;e=0.001;c=[5;4;3;2;1]Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];x=[x1;x2;x3;x4;x5]f=c'*x+0.5*x'*Q*xtidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]x1=0;x2=0;x3=0;x4=0;x5=0;flag=1;k=0;t
matlab2013b 运行正常.
但是t的确是sym变量而不是数值.

求MATLAB高手帮忙改下程序,我的有错误啊,像画三条曲线出来的syms x1 x2 x3 t x%x1=S,x2=I,x3=R%微分表达式%x=[x1;x2;x3];function xdot=DxDt(t,x)xdot=[-0.0000003*x1.*x2-0.001*x1;0.0000003*x1.*x2-0.025*x2;0.001*x1+0.025*x2];t=[0,20 Matlab错误求改.急syms x1 x2 x3 x4 x5;e=0.001;c=[5;4;3;2;1]Q=[5 4 3 2 1;4 4 3 2 1;3 3 3 2 1;2 2 2 2 1;1 1 1 1 1];x=[x1;x2;x3;x4;x5]f=c'*x+0.5*x'*Q*xtidu=[diff(f,x1);diff(f,x2);diff(f,x3);diff(f,x4);diff(f,x5)]x1=0;x2=0;x3=0;x4=0;x5=0;flag=1;k=0;t matlab求梯度syms x1 x2f=x1^2+x2^2求f的梯度,结果为[2*x1 2*x2]',怎么求 matlab中,希望求函数f(x)=x的1/3次方,及其导函数z=df(x)/dx程序如下:syms x; f=nthroot(x,3); f1=diff(f);pretty(f1);x1=-5:0.1:5;y=subs(f,x,x1);y1=subs(f1,x,x1);plot(x1,y,x1,y1,':');第二行f=nthroot(x,3);错误若第二行改为f=x^(1/ MATLAB 中syms 急.如何用matlab绘制方程图像?12*x1*x2-32*x1=0; 我用的代码是:syms x1 x2ezplot('12*x1*x2-32*x1=0')结果只显示了俩坐标轴,没有图像.可是用这种方法画x1=x2就能显示. 我在matlab中输入syms t ,怎么老显示错误 matlab生成x1 x2 x3i写一个matlab脚本,根据i值,循环产生符号比如i=3,则产生syms x1 x2 x3若i=4,则产生syms x1 x2 x3 x4 用matlab 求泰勒展开求在f=x1^4-3*x1-2*x1^2*x2+x2^2+8,在[1,2]T点处的二阶泰勒展开式syms x1 x2;taylor(x1^4-3*x1-2*x1^2*x2+x2^2+8,3) ans = x2^2 - 3*x1 - 2*x1^2*x2 + 8 我写的这个求出来的是什么?和答案不一样 matlab中syms什么意思? matlab 符号矩阵在某点的值.syms x1,x2,x3经过杂的运行得:f=[x1 + 3*x2 + 3*x1*x2 - x1*x3 + 2*x1*x2^2 + 2*x2^2 + 1;x3*(x2 + 1);- 3*x1^2 - 3*x1 - 2*x3*x2^2 - 3*x3*x2 - x3]我想求f当x1=1,x2=2,x3=3时的值,语句应该是什么样的呢 在matlab中,运用共轭梯度求二次函数极小点,程序老是会出现以下状况,请大仙帮我看看,哪边错了?syms x1 x2 kf=(3/2)*(x1^2)+(1/2)*(x2^2)-x1*x2-2*x1;A=[3 -1;-1 1];x_1=[-2;4];fx1=diff(f,x1);fx2=diff(f,x2);fx1_1=subs(fx1,{x1, matlab中怎么求二元二次方程组我在计算的时候出现这个结果{syms x y;>> solve('x^2+y^2+30*y=175','x^2-90*x+y^2=-800')ans = x:[2x1 sym]y:[2x1 sym]}这个X、Y似乎不是我要的数值,更主要的是看不懂, 求个非线性方程组,六个参数,急.用MATLAB 求不出来哈,代码如下>> syms qn dn dr pn pr cn cr sn sr hn hr t e a o A T u1 k>> syms Fn Fr fn fr>> syms zn zr>>o=0.8;>>a=0.1;>>cn=0.4;>>cr=0.2;>>k=2;>>T=1;>>hn=0.1;>>sn=0.1;>>hr=0.05;>>sr=0. matlab程序运行出现the statement is incomplete的错误,下面是程序,请问怎样解决clear all;syms a b;X=[2 3 5 6];Y=[3 4 6 8];for m=1:2x1=X(m); y1=Y(m); x2=X(m+1); y2=Y(m+1); x3=X(m+2); y3=Y(m+2);p1=-b-((x3-x1)/(y3-y1))*(a-x2)+y2; %方 matlab带参数的二元函数求最大值问题syms v x1 x2 g L1 L2S=(v^2*sin(2*x2)+2*v*sin(x2)*sqrt(v^2*(cos(x2))^2+2*g*(L1*sin(x1)+L2*sin(x2))))/(2*g)Sx1=diff(S,x1);Sx2=diff(S,x2);solve(Sx1,'x1')solve(Sx2,'x2')Error using ==> solveUnable to find c 在matlab中,如何把符号表达式变成数值表达式例如syms x1 x2;s=3*x1 - x2 - 2;我要让x1=2,x2=3来计算s的值, matlab 变量x1和x(1)例如syms x1 x2 x3 realf=2*x1+3*x2+5*x3如何转换为f=2*x(1)+3*x(2)+5*x(3)