I'm trying to plot the eigenvalues of a symbolic 3x3 matrix using the code below:
syms kx ky phi;
assume(kx,'real'); assume(ky, 'real'); assume(phi,'real');
cx = (1+exp(-1i*kx));
cy = (1+exp(-1i*ky));
H0 = [0 cx cy; conj(cx) 0 0; conj(cy) 0 0];
eig0 = eig(H0);
for ie = 1:3
fsurf(eig0(ie),[0,2*pi,0,2*pi],'edgecolor','none'); hold on;
end
hold off
xlabel('k_x/a'); ylabel('k_y/a');
As you can see the resulting plot is terrible,as there are holes everywhere. If I use ezsurf instead it is working fine.
Is it a bug of fsurf or am I missing something?

 Accepted Answer

The MATLAB plot functions do not plot imaginary numbers.
Try this:
hold on
for ie = 1:3
fsurf(real(eig0(ie)),[0,2*pi,0,2*pi],'edgecolor','none')
fsurf(imag(eig0(ie)),[0,2*pi,0,2*pi],'edgecolor','none')
end
hold off
view(-30,30)
xlabel('k\_x/a'); ylabel('k\_y/a')
Experiment to get different results.
.

2 Comments

Thank you, this worked perfectly.
I knew they had to be all real so I did not bother to enforce it but of course matlab did not know :)
As always, my pleasure!
As with all computer languages, it is necessary to tell MATLAB everything you want it to do!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!