如何使用Matlab​程序求解极值点(函数​表达式有两个符号变.​..

clear all
close all
clc
syms sita1 sita2;
Z=[1 0 0
0 exp(i*2*pi/3) 0
0 0 exp(i*4*pi/3)];
X=[0 0 1
1 0 0
0 1 0];
XZ=X*Z;
[A,V1]=eig(Z);
[B,V2]=eig(X);
[C,V3]=eig(XZ); %求解特征向量;
c=[1/sqrt(3);1/sqrt(3)*exp(i*sita1);1/sqrt(3)*exp(i*sita2)];
CC=[c,c,c];
z=sum(abs(dot(B,CC)))+sum(abs(dot(C,CC)));
%做内积,此后,要对z进行求解极值点,z为sita1,sita2的函数。
%----------------------------------------------------------------------
dzsita1=diff(z,sita1)
dzsita2=diff(z,sita2)
S=solve(dzsita1==1,dzsita2==1,sita1,sita2); %S求解不出来,程序在此中遇到的难题了

 Respuesta aceptada

sihexa
sihexa el 25 de Nov. de 2022

0 votos

你的表达式有点复杂,用 solve 无法求出符号解。
可以考虑用 fsolve 求解数值解,不过,需要将方程组定义为函数句柄。你可以将最后一句改为:
f = matlabFunction([dzsita1;dzsita1]);
f = @(x) f(x(1),x(2));
fsolve(f,[1 1])
最后一句的 [1 1] 是方程组求解的初值,你要是能知道解的大致范围,就换做相应的范围。数值求解的一个缺点就是对初值敏感,必须指定一个合理的初值

Más respuestas (0)

Categorías

Más información sobre 编程 en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de Nov. de 2022

Respondida:

el 25 de Nov. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!