previous: eigenvectors,SVD
next: integration

09: Plot y(x) and z(x,y)

Plot a function of 1 variable (line graph)
and a function of 2 variables (surface plot)

Plot   y = sin(4x)   for 2.2<x<4.4

Plot   z = sin(4x)cos(3y)   over 2.2<x<4.4,   1.1<y<3.5

Mathematica:

Plot[ Sin[4x], {x,2.2,4.4}];

Plot3D[ Sin[4x]Cos[3y],
    {x,2.2,4.4}, {y,1.1,3.5} ];

Matlab:

Create data points explicitly...
x = 2.2:0.1:4.4;
y = sin(4*x);
plot(x,y)

or
syms x y
y = sin(4*x)
ezplot(y, [2.2,4.4])

x = 2.2:0.1:4.4;
y = 1.1:0.1:3.5;
z = meshgrid(x,y)
for i=1:23
  for k=1:25
    z(k,i)= sin(4*x(i))*cos(3*y(k));
  end
end
surf(x,y,z)

or
syms u v z
z = sin(4*u) * cos(3*v)
ezsurf(z, [2.2,4.4], [1.1,3.5])
Maple:

plot( sin(4*x), x=2.2..4.4 );

plot3d( sin(4*x)*cos(3*y),
    x=2.2..4.4, y=1.1..3.5);

IDL:

x = findgen(23)/10 + 2.2   (data points at 2.2, 2.3, ...)
plot, x, sin(4*x)

y = findgen(25)/10 + 1.1   (data points at 1.1, 1.2, ...)
z = sin(4*x) # cos(3*y)   (using # as ``outer product'')
shade_surf, z, x,y   (or surface, z, x,y)