How can I plot this function?

1 次查看(过去 30 天)
Aisha Mohamed
Aisha Mohamed2022-10-27
评论: Star Strider ,2022-10-27
Hi all
I have this function ,
where x and p any real number and $\lambda$ is complex number
How can I plot this function by using matlab.
Iappreciate any help

回答(2 个)

Chunru 2022-10-27
% parameters (use your values)
lambdaR = 1;
lambdaI = -1;
d = 3;
p = 2;
x = -10:.1:10;
w = sqrt(pi/2)*exp((-p^2-4*p*lambdaI-4*lambdaI^2-16*x.^2+16*lambdaR*x+16*d)/8);
plot(x, w)

Star Strider
Star Strider 2022-10-27
编辑:Star Strider 2022-10-27
This requires a surface plot with separate plots for the real and imaginary components —
lambdaI = randn; % Random Complex Scalar
lambdaR = randn; % Random Complex Scalar
d = randn; % Random Scalar
W = @(x,p) sqrt(pi/2) * exp((-p.^2 -4*p.*lambdaI -4*lambdaI.^2 - 16*x.^2 + 16*lambdaR.*x + 16*d)/8);
x = linspace(-2.5, 2.5, 50);
p = linspace(-5, 5, 50);
[X,P] = ndgrid(x,p);
grid on
  4 个评论
Star Strider
Star Strider 2022-10-27
@Torsten — I fixed the and to both be real, however the variables are ‘x’ and ‘p’ so I plotted the surface with those as . I have no idea if λ is a vector, so I assume it’s a scalar here.


Community Treasure Hunt

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

Start Hunting!

Translated by