Register to reply

Plotting two vectors and a function in MATLAB

by geft
Tags: function, matlab, plotting, vectors
Share this thread:
geft
#1
Mar16-12, 01:58 AM
P: 148
This may seem stupid, but I can't figure out how to plot the following function in MATLAB:

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;
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.

Never mind, guys. I got it. You have to convert each variable into matrices by using the meshgrid function.
Phys.Org News Partner Science news on Phys.org
Security CTO to detail Android Fake ID flaw at Black Hat
Huge waves measured for first time in Arctic Ocean
Mysterious molecules in space

Register to reply

Related Discussions
MATLAB function plotting Engineering, Comp Sci, & Technology Homework 2
Plotting max function in matlab Math & Science Software 0
Help! plotting transfer function in matlab.. Math & Science Software 6
Plotting a function - MATLAB Math & Science Software 2
Plotting vectors in Maple or MATLAB Math & Science Software 2