hengameh
(Hengameh Bagherianlemraski)
1
I want to define a function with the following variables :
g21
g31 = 50
d2 = 20
d = d2 - d1
k = 10
geff =10
O1 = 0.001
O2 = 10
And the function itself is defined as :
f[d1_] = O1*geff*(i*g21-2*d)/
((0.5*g21*(-g31+2*d1)+ d*(-i*g31-2*d1)-0.5*(O2)^2)*i*k +geff^2*(4*d-2*i*g21))
And then I want to use Manipulate[] to see how the function changes for different values of g_21 :
Manipulate[Plot[Abs[f[d1]], {d1, -40, 40}], {g21, 1, 50}]
But I get a blank plot instead.
I would really appreciate it if someone could help me on this. Thanks in advance
vaungureanu
(Valeriu Ungureanu)
2
Your code have some undefined variables. I have done several modifications and propose you to adapt the following code to your needs:
g31 = 50; d2 = 20; k = 10; geff = 10; O1 = 0.001; O2 = 10;
f[d1_, g21_, i_] :=
O1*geff*(i*g21 -
2*(d2 - d1))/((0.5*
g21*(-g31 + 2*d1) + (d2 - d1)*(-i*g31 - 2*d1) - 0.5*(O2)^2)*
i*k + geff^2*(4*(d2 - d1) - 2*i*g21))
Manipulate[
Plot[Abs[f[d1, g21, i]], {d1, -40, 40}], {g21, 1, 50}, {i, 1, 10}]
hengameh
(Hengameh Bagherianlemraski)
3
āiā is the imaginary i.
i^2 = -1.
vaungureanu
(Valeriu Ungureanu)
4
If i is imaginary, then:
f[d1_, g21_] :=
O1*geff*(I*g21 -
2*(d2 - d1))/((0.5*
g21*(-g31 + 2*d1) + (d2 - d1)*(-I*g31 - 2*d1) - 0.5*(O2)^2)*
I*k + geff^2*(4*(d2 - d1) - 2*I*g21))
Manipulate[
Plot[Abs[f[d1, g21]], {d1, -40, 40}, PlotRange -> All], {g21, 1, 50}]
hengameh
(Hengameh Bagherianlemraski)
5
Here is what I get when I run the code :
vaungureanu
(Valeriu Ungureanu)
6
You must clear f. You can use also:
Remove["Global`*"]
After that you need to define all variables and function.
hengameh
(Hengameh Bagherianlemraski)
7
Thank you so much! its working now!