Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 多个LHS分配的数组不能包含LEX_TS_字符串错误_Matlab - Fatal编程技术网

Matlab 多个LHS分配的数组不能包含LEX_TS_字符串错误

Matlab 多个LHS分配的数组不能包含LEX_TS_字符串错误,matlab,Matlab,matlab编程新手。我目前正在尝试制作一个MATLAB程序,该程序将找到多变量函数的临界值,并告诉我每个值是最小值、最大值还是鞍点。不幸的是,我总是会遇到这样的错误:用于多个LHS赋值的数组不能包含LEX_TS_字符串 任何帮助都将不胜感激 代码如下: function [c,d] = critcalpoints(f) syms x y f(x,y)=x^3-3*x^2+5*x*y-7*y^2; gradf = jacobian(f(x,y)); hessmatf = jacobian(gr

matlab编程新手。我目前正在尝试制作一个MATLAB程序,该程序将找到多变量函数的临界值,并告诉我每个值是最小值、最大值还是鞍点。不幸的是,我总是会遇到这样的错误:用于多个LHS赋值的数组不能包含LEX_TS_字符串

任何帮助都将不胜感激

代码如下:

function [c,d] = critcalpoints(f)

syms x y
f(x,y)=x^3-3*x^2+5*x*y-7*y^2;
gradf = jacobian(f(x,y));
hessmatf = jacobian(gradf,[x,y]);
[xcr,ycr]=solve(gradf(1),gradf(2));
H1=subs(hessmatf,[x,y],[xcr(1),ycr(1)]);
H2=subs(hessmatf,[x,y],[xcr(2),ycr(2)]);
eig(H1);
eig(H2);
c = double(eig(H1));
d = double(eig(H2));
if (c(1) > 0 && d(1) > 0) || (c(2) > 0 && d(2) > 0)
print([xcr,ycr],' is a minimum')
elseif (c(1) < 0 && d(1) < 0) || (c(2) < 0 && d(2) < 0)
print( [xcr, ycr], ' is a maximum')
elseif (c(1) < 0 && d(1) > 0) || (c(1) > 0 && d(1) < 0)
print( [xcr, ycr], ' is a saddle point')
elseif (c(2) < 0 && d(2) > 0) || (c(2) > 0 && d(2) < 0)
print( [xcr, ycr], ' is a saddle point')
elseif (c(1)==0 || d(1)==0)
print( [xcr, ycr], ' is degenerate')
elseif (c(2)==0 || d(2)==0)
print( [xcr, ycr], ' is degenerate')
end
函数[c,d]=临界点(f)
syms x y
f(x,y)=x^3-3*x^2+5*x*y-7*y^2;
gradf=雅可比(f(x,y));
hessmatf=雅可比(gradf,[x,y]);
[xcr,ycr]=solve(gradf(1),gradf(2));
H1=subs(hessmatf[x,y],[xcr(1),ycr(1)];
H2=subs(hessmatf[x,y],[xcr(2),ycr(2)];
eig(H1);
eig(H2);
c=双(eig(H1));
d=双(eig(H2));
如果(c(1)>0&&d(1)>0)| |(c(2)>0&&d(2)>0)
打印([xcr,ycr],“是最小值”)
elseif(c(1)<0&&d(1)<0)| |(c(2)<0&&d(2)<0)
打印([xcr,ycr],“是最大值”)
elseif(c(1)<0&&d(1)>0)| |(c(1)>0&&d(1)<0)
打印([xcr,ycr],“是鞍点”)
elseif(c(2)<0&&d(2)>0)| |(c(2)>0&&d(2)<0)
打印([xcr,ycr],“是鞍点”)
elseif(c(1)==0 | | d(1)==0)
打印([xcr,ycr],“是退化的”)
elseif(c(2)==0 | | d(2)==0)
打印([xcr,ycr],“是退化的”)
结束

无法重现您的错误。代码可以工作,但您需要将
print
更改为其他内容,因为
print
不会执行您认为它会执行的操作。该函数用于打印打开文件的地物。更改它,以便首先显示
xcr
ycr
,然后显示要满足的正确条件。改用
disp

syms x y
f(x,y)=x^3-3*x^2+5*x*y-7*y^2;
gradf = jacobian(f(x,y));
hessmatf = jacobian(gradf,[x,y]);
[xcr,ycr]=solve(gradf(1),gradf(2));
H1=subs(hessmatf,[x,y],[xcr(1),ycr(1)]);
H2=subs(hessmatf,[x,y],[xcr(2),ycr(2)]);
eig(H1);
eig(H2);
c = double(eig(H1));
d = double(eig(H2));
disp([xcr, ycr]); % Display the solutions first

if (c(1) > 0 && d(1) > 0) || (c(2) > 0 && d(2) > 0)
disp('is a minimum')
elseif (c(1) < 0 && d(1) < 0) || (c(2) < 0 && d(2) < 0)
disp('is a maximum')
elseif (c(1) < 0 && d(1) > 0) || (c(1) > 0 && d(1) < 0)
disp('is a saddle point')
elseif (c(2) < 0 && d(2) > 0) || (c(2) > 0 && d(2) < 0)
disp('is a saddle point')
elseif (c(1)==0 || d(1)==0)
disp('is degenerate')
elseif (c(2)==0 || d(2)==0)
disp('is degenerate')
end
[     0,       0]
[ 59/42, 295/588]

is a maximum