Mercurial > hg > octave-lyh
comparison scripts/plot/peaks.m @ 7282:30100a15625c
[project @ 2007-12-10 21:42:11 by jwe]
author | jwe |
---|---|
date | Mon, 10 Dec 2007 21:42:11 +0000 |
parents | 5389a52df87b |
children | dbd0c77e575e |
comparison
equal
deleted
inserted
replaced
7281:add731f4024d | 7282:30100a15625c |
---|---|
44 ## the range @code{[-3,3]}. The default value for @var{n} is 49. | 44 ## the range @code{[-3,3]}. The default value for @var{n} is 49. |
45 ## | 45 ## |
46 ## If @var{n} is a vector, then it represents the @var{x} and @var{y} values | 46 ## If @var{n} is a vector, then it represents the @var{x} and @var{y} values |
47 ## of the grid on which to calculate the above function. The @var{x} and | 47 ## of the grid on which to calculate the above function. The @var{x} and |
48 ## @var{y} values can be specified separately. | 48 ## @var{y} values can be specified separately. |
49 ## @seealso{mesh} | 49 ## @seealso{surf, mesh, meshgrid} |
50 ## @end deftypefn | 50 ## @end deftypefn |
51 | 51 |
52 ## Expression for the peaks function was taken from the following paper: | 52 ## Expression for the peaks function was taken from the following paper: |
53 ## http://www.control.hut.fi/Kurssit/AS-74.115/Material/GENALGgoga.pdf | 53 ## http://www.control.hut.fi/Kurssit/AS-74.115/Material/GENALGgoga.pdf |
54 | 54 |
74 Z = 3 * (1 - X) .^ 2 .* exp(- X .^ 2 - (Y + 1) .^ 2) \ | 74 Z = 3 * (1 - X) .^ 2 .* exp(- X .^ 2 - (Y + 1) .^ 2) \ |
75 - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) \ | 75 - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) \ |
76 - 1 / 3 * exp(- (X + 1) .^ 2 - Y .^ 2); | 76 - 1 / 3 * exp(- (X + 1) .^ 2 - Y .^ 2); |
77 | 77 |
78 if (nargout == 0) | 78 if (nargout == 0) |
79 mesh (x, y, Z); | 79 surf (x, y, Z); |
80 elseif (nargout == 1) | 80 elseif (nargout == 1) |
81 X_out = Z; | 81 X_out = Z; |
82 else | 82 else |
83 X_out = X; | 83 X_out = X; |
84 Y_out = Y; | 84 Y_out = Y; |