Plotting a potential function in MATLAB

In summary, the conversation discusses plotting a function in MATLAB with a specific potential equation. The function depends on m^2, lambda, and phi1, phi2 which are defined as real numbers. The surf() function in MATLAB is suggested for this purpose and an example is provided. There is also a mention of encountering this while studying QFT and looking to demonstrate spontaneous U(1) symmetry breaking. The conversation ends with a thank you and confirmation of success in plotting the function.
  • #1
maxtor101
24
0
Hi all,

I would like to be able to plot this function in MATLAB[itex] \mathcal{V} (\phi_{1}, \phi_{2}) = m^2(\phi_{1}^2 + \phi_{2}^2) + \lambda( \phi_{1}^2 + \phi_{2}^2)^2[/itex]Where [itex] \phi_{1,2} , m^2 , \lambda \in \mathbb{R} [/itex] and [itex] \lambda > 0 [/itex]I am aware that the cases [itex] m^2 > 0 [/itex] and [itex] m^2 < 0 [/itex] 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
 
Physics news on Phys.org
  • #2
Hello Maxtor,

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

After defining [itex] \phi_1, \phi_2, V [/itex] 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

All the best,
Yuu
 
Last edited by a moderator:
  • #3
Thank you for your reply!

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
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)
thanks for your help!
 
  • #5
You are very welcome :smile:
 

1. How do I plot a potential function in MATLAB?

To plot a potential function in MATLAB, you can use the "plot" function. First, define the potential function as a mathematical expression using variables. Then, use the "plot" function to plot the potential function against the desired range of values for the variables. Make sure to label the axes and add a title to the plot for clarity.

2. Can I plot a 3D potential function in MATLAB?

Yes, you can plot a 3D potential function in MATLAB using the "surf" function. This function creates a 3D surface plot of the potential function. You can also use the "contour" function to create a 2D contour plot of the potential function.

3. How can I customize the appearance of my potential function plot?

You can customize the appearance of your potential function plot in MATLAB by using various formatting options. For example, you can change the color and style of the plot line, add grid lines, and adjust the axes limits and labels. You can also add a legend, change the font style, and add annotations to your plot.

4. Is it possible to plot multiple potential functions on the same graph?

Yes, it is possible to plot multiple potential functions on the same graph in MATLAB. To do this, define each potential function as a separate variable and use the "hold on" function before plotting each function. This will allow you to plot multiple functions on the same graph and customize the appearance of each function individually.

5. Can I save my potential function plot as an image file?

Yes, you can save your potential function plot as an image file in MATLAB. After creating your plot, you can use the "saveas" function to save it as a specific file type, such as PNG, JPEG, or PDF. You can also specify the resolution and size of the saved image. This is useful for including your potential function plot in presentations or reports.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
635
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
248
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
987
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top