MATLAB Plotting a potential function in MATLAB

1. Nov 14, 2012

maxtor101

Hi all,

I would like to be able to plot this function in MATLAB

$\mathcal{V} (\phi_{1}, \phi_{2}) = m^2(\phi_{1}^2 + \phi_{2}^2) + \lambda( \phi_{1}^2 + \phi_{2}^2)^2$

Where $\phi_{1,2} , m^2 , \lambda \in \mathbb{R}$ and $\lambda > 0$

I am aware that the cases $m^2 > 0$ and $m^2 < 0$ yield two different plots.

I encountered this while doing some reading on QFT, this potential was used in a Lagrangian density while trying to demonstrate spontaneous U(1) symmetry breaking.

I would really like to be able to plot this in MATLAB but unfortunately I have minimal previous experience with it.

Would anybody here be able to help me please?

Thanks
Max

2. Nov 14, 2012

Yuu Suzumi

Hello Maxtor,

I believe the surf() function in matlab to be suited for your purposes.

After defining $\phi_1, \phi_2, V$ in MATLAB you would use it in this way:
surf(phi_1, phi_2, V). Information and examples are available here:

http://www.mathworks.de/de/help/matlab/ref/surf.html [Broken]

All the best,
Yuu

Last edited by a moderator: May 6, 2017
3. Nov 14, 2012

maxtor101

phi1 = [-20:0.5:20];
phi2 = [-20:0.5:20];
lam = 1;
m = 1;

V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;

surf(phi1, phi2, V)

I tried this but I get the following error:

Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

Error in p1a (line 6)
V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;

4. Nov 14, 2012

maxtor101

Apologies, I got it working

[phi1, phi2] = meshgrid(-20:0.5:20);

lam = 1;
m = 1;

V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;

surf(phi1, phi2, V)