matlab矩阵变量

来源:百度知道 编辑:UC知道 时间:2024/07/08 02:56:54
我想求 matrix A=[sinw 1
cosw sinw]
我想得到 当w从0到2pi(x轴),eigenvalue of A的值(y轴)
应该怎么写?
why I changed the size of matrix, the error "Subscripted assignment dimension mismatch." appear? Thank you for you reply.

A=@(w)[sin(w) 1;cos(w) sin(w)];

f=@(w)eig(A(w));

w=linspace(1e-7,2*pi-1e-7);

for i=1:100

    y(:,i)=f(w(i));

end

figure('color','w')

plot3(w,real(y),imag(y));

set(gca,'xtick',linspace(0,2*pi,7),'xticklabel',{'0','π/3','2π/3','π','4π/3','5π/3','2π'});

xlabel('\omega');ylabel('特征值实部');zlabel('特征值虚部');

legend('\lambda_1','\lambda_2','location','northeast');

title(['Eigenvalues of A=$$',latex(sym('[sin(omega) 1;cos(omega) sin(omega)]')),'$$'],'interpreter','latex','VerticalAlignment','middle');

——————————————————————————————

before you change the matrix, you should clear all the variables, or some&