Hey, my code is
if
clear
hbar = 6.582119e-01; % Planck constant (meV ps)
clf reset;
Delta = 1.0;
tau = 0.5;
o = 3./hbar;
A = 1;
[omega,d] = meshgrid(0:0.25:7,0:0.25:7);
syms k(omega) l_1(omega) l_2(omega)
k_0 = (omega-2.*Delta)./(omega+2.*Delta);
k(omega) = piecewise(2.*Delta<= omega, k_0, 0); % the 0 is just random to stay inside the definition interval of the elliptic functions; later I cut them off by the heaviside function
l_1_0 = (o-omega-2.*Delta)./(-omega+o+2.*Delta);
l_1(omega) = piecewise(o-2.*Delta<= omega, l_1_0, 0);
l_2_0 = (omega-o-2.*Delta)./(omega-o+2.*Delta);
l_2(omega) = piecewise(o+2.*Delta<= omega, l_2_0, 0);
[K,E] = ellipke(k(omega));
[L_1,F_1] = ellipke(l_1(omega));
[L_2,F_2] = ellipke(l_2(omega));
Resi_0 = pi./8.*((1+2.*Delta./omega).*E-(4.*Delta./omega).*K).*heaviside(omega-2.*Delta);
Resi_l_1 = -2.*pi./8.*A.*(((1+2.*Delta./(o-omega)).*L_1-(4.*Delta./(o-omega).*F_1).*heaviside(o-omega-2.*Delta)).*sin(o.*d));
Resi_l_2 = 2.*pi./8.*A.*(((1+2.*Delta./(omega-o).*L_2-4.*Delta./(omega-o).*F_2).*heaviside(omega-o-2.*Delta)).*sin(o.*d));
Resigma = Resi_0 + Resi_l_1 + Resi_l_2;
plot3(d,omega,Resigma); % I tried plot3 and fplot3, both with the same error
hold on
view(-35,45)
axis([-.5 10.5 -.5 10.5 0 1.5])
hold off
end
I really don't understand why matlab doesn't want to do what I want it to do...the error I get is:
if true
Error using plot3
Data must be numeric, datetime, duration or an array convertible to double.
Error in gamma (line 30)
plot3(d,omega,Resigma);
end
I would really appreciate any kind of help...

 Réponse acceptée

Jason Whitfield
Jason Whitfield le 19 Juil 2018
Modifié(e) : Jason Whitfield le 19 Juil 2018

1 vote

In your code, the following line will overwrite your "omega" variable with a symbolic variable.
syms k(omega) l_1(omega) l_2(omega)
You can fix this issue by replacing the "omega" variable in your symbolic functions with some unused name.

3 commentaires

Rebecca Müller
Rebecca Müller le 19 Juil 2018
Modifié(e) : Rebecca Müller le 19 Juil 2018
Thanks, I did so (I just called k(omega) k, l_1(omega) l_1,..), but now I get the error:
if
Undefined function 'piecewise' for input arguments of type 'double'.
Error in gamma (line 14)
k = piecewise(2.*Delta<= omega, k_0, 0);
end
Your symbolic functions still need to have a parameter, it just can't be called "omega." You could call it "x" instead. Then, the first function would look something like this:
syms k(x) l_1(x) l_2(x)
k_0 = (x-2.*Delta)./(x+2.*Delta);
k(x) = piecewise(2.*Delta<= x, k_0, 0);
[K,E] = ellipke(k(omega));
with the replacement you suggested before editing your first answer:
if
k_0 = (omega-2.*Delta)./(omega+2.*Delta );
k(omega) = piecewise(2.*Delta<= omega, k_0, 0 );
[K,E] = ellipke(k(omega));
Would become this:
k = (omega-2.*Delta)./(omega+2.*Delta ); k(2.*Delta > omega) = 0 ; [K,E] = ellipke(k); end it worked!!! Thank you very much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by