
How can I plot this function?
    8 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hi all
I have this function ,
$W(x,p)=\sqrt{\frac{\pi}{2}}exp(\frac{(-p^2)-4p\lambda_I-4\lambda_{I}^2-16x^2+16\lambda_Rx+16d}{8})$

where x and p any real number and $\lambda$ is complex number
How can I plot this function by using matlab.
Iappreciate any help
0 commentaires
Réponses (2)
  Chunru
      
      
 le 27 Oct 2022
        
% 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)
0 commentaires
  Star Strider
      
      
 le 27 Oct 2022
        
      Modifié(e) : Star Strider
      
      
 le 27 Oct 2022
  
      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);
figure
surfc(X,P,real(W(X,P)))
grid on
colormap(turbo)
xlabel('x')
ylabel('p')
zlabel('W(x,p)')
.
4 commentaires
  Torsten
      
      
 le 27 Oct 2022
				I think there is nothing complex in W (lambda_I and lambda_R are both real).
Thus the plot should be over real tuples (lambda_R,lambda_I), I guess.
But maybe the OP can clarify.
  Star Strider
      
      
 le 27 Oct 2022
				@Torsten — I fixed the  and
 and  to both be real, however the variables are ‘x’ and ‘p’ so I plotted the surface with those as
 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.
.  I have no idea if λ is a vector, so I assume it’s a scalar here.  
 and
 and  to both be real, however the variables are ‘x’ and ‘p’ so I plotted the surface with those as
 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.
.  I have no idea if λ is a vector, so I assume it’s a scalar here.  Voir également
Catégories
				En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





