This may seem stupid, but I can't figure out how to plot the following function in MATLAB:(adsbygoogle = window.adsbygoogle || []).push({});

I don't know how to include the second variable such that the function produces a 3D plot. Instead I get a 2D curve which seems to assume the second variable as a constant.Code (Text):x1 = -5:1:10;

x2 = 0:1:15;

func = (x2-5.1*x1.^2/(2*pi).^2+5*x1/pi-6).^2+10*cos(x1)*(1-1/(8*pi))+10;

Never mind, guys. I got it. You have to convert each variable into matrices by using the meshgrid function.

**Physics Forums - The Fusion of Science and Community**

# Plotting two vectors and a function in MATLAB

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

- Similar discussions for: Plotting two vectors and a function in MATLAB

Loading...

**Physics Forums - The Fusion of Science and Community**