How Matlab draws the envelopes of complex curves
Http://jingyan.baidu.com/article/aa6a2c14d36c710d4c19c4a8.html
If a curve, such as a sound waveform, fluctuates greatly and is complex, it can be smoother and clearer by drawing envelopes. This experience helps newcomers to new MATLAB to complete this process.
Tools/Materials
Matlab Software
Sample Data
Method/Step
Before and after the treatment of the effect of the comparison, illustrated by a sound wave Fourier transform (FFT) after the spectral map.
The original data for the horizontal ordinate for frequency and amplitude, are <2048x1 double> data, that is, contains 2048 data points, by subplot (2,2,1), Plot (fr,am); Drawn.
The formation of envelopes, it is necessary to divide the original data into small segments of equal width, each section takes a high point corresponding to the horizontal axis and ordinate (). For example, set the length of each small segment to D = 4 or 8 or 16 (or 2048 for other approximate), and then run
Y=reshape (AMPLITUDE,D,2048/D);
Y=max (y);
X=linspace (0,max (frequency), 2048/d);
The resulting x and y are the horizontal ordinate of the envelope line.
The key functions are reshape () and linspace ().
The reshape () function resizes the number of rows, columns, and dimensions of the matrix. Reshape (x,m,n) can adjust the matrix X to a matrix of m rows n columns, such as:
>> reshape ([1 2 3 4 5 6],2,3)
Ans =
1 3 5
2 4 6
Linspace () is used to produce linear vectors. Linspace (A,b,n) can produce a one-dimensional array of a total of n elements from A to B. Like what:
>> Linspace (1,5,4)
Ans =
1.0000 2.3333 3.6667 5.0000
How Matlab draws the envelopes of complex curves