Please refer to the sourceProgram:
Clear, CLC; format longx = (0: 0. 0:100) '; y_0 = besselj (0, x); % Y_1 = besselj (1, x); % level 1. Here, only order 0% y_2 = besselj (2, x); % second-order plot (x, y_0); grid on; axis ([0,100,-]); Title ('0-order besell Function Curve '); xlabel ('variable x'); ylabel ('variable y'); % draw envelope hold on; [Up, down] = envelope (x, y_0, 'spline '); plot (x, up, 'R'); plot (x, down, 'R ');
The envelope is a separate. M file, which is a function used to draw an envelope. To put it bluntly, it is to calculate the inflection point and then interpolation:
Function [Up, down] = envelope (X, Y, interpmethod) % envelope gets the data of upper and down envelope of the known input (x, y ). % input parameters: % x the abscissa of the given data % Y the ordinate of the given data % interpmethod the interpolation method % output parameters: % up the upper envelope, which has the same length as X. % down the down envelope, which has the same length as X. % See also diff Interp1 % designed by: Lei Wang, <WangLeiBox@hotmail.com>, 11-Mar-2003.% last revision: 21-Mar-2003.% Dept. mechanical & aerospace engineering, NC State University. % $ revision: 1.1 $ Date: 3/21/2003 am $ if length (x )~ = Length (y) error ('two input data shocould have the same length. '); endif (nargin <2) | (nargin> 3), error ('Please see help for input data. '); elseif (nargin = 2) interpmethod = 'linear '; end % find the extreme Maxim values % and the corresponding indexes % values extrmaxvalue = Y (find (diff (sign (diff (y) =-2) + 1 ); extrmaxindex = find (diff (sign (diff (y) =-2) + 1; % find the extreme minim values % and the corresponding indexes % values extrminvalue = Y (find (diff (sign (diff (y) = + 2) + 1 ); extrminindex = find (diff (sign (diff (y) = + 2) + 1; up = extrmaxvalue; up_x = x (extrmaxindex); down = extrminvalue; down_x = x (extrminindex); % interpolation of the Upper/down envelope data % merge up = interp1 (up_x, up, X, interpmethod); down = interp1 (down_x, down, x, interpmethod );
Effect:
Source program download: http://www.pudn.com/downloads495/sourcecode/windows/other/detail2062657.html
No MATLAB exists in the resource tags Uploaded By csdn. Why ....