matlabfft简单例子(matlabfft简单例子)
matlabfft简单例子(matlabfft简单例子)
N=128;
N=0:N-1;
T=n/fs;
F0=10;% sets sine signal frequency
% generates sinusoidal signals
X=sin (2*pi*f0*t);
Figure (1);
Subplot (231);
Plot (T, x)% sinusoidal waveform in time domain
Xlabel ('t');
Ylabel ('y');
Title (` sine signal, y=2*pi*10t time domain waveform ');
Grid;
% to do FFT transform and do frequency spectrum
Y=fft (x, N);% performs the FFT transform
Mag=abs (y);% for magnitude
F= (0:length (y) -1)'*fs/length (y);% corresponding frequency
conversion
Figure (1);
Subplot (232);
Plot (F, MAG):% do spectrogram
Axis ([0100,0,80]);
Xlabel (` frequency (Hz) ');
Ylabel ('amplitude');
Title (sine signal y=2*pi*10t amplitude spectrum N=128');
Grid;
MATLAB's FFT program 2009-11-08 16:30clc
X% input signal
M=nextpow2 (x);% x length corresponds to the minimum power m
of 2
N=2^M;
If length (x) x (i), (j).
temp = x (i);
x = x (i), (j);
x (j) = temp;
end
end
end
y = x;
以上为按照升序排列的, 若要降序, 则
if x < x (i), (j).
temp = x (i);
x = x (i), (j);
x (j) = temp;
冒泡%
the clc; clear;
x = rand (1,10);
for i = 1: length (x)
for j = 1: length (x) - (i)
if (x > x (j), (j + 1))
t = x (j);
x (j) = x (j + 1);
x (j + 1) = t;
end
end
end
disp (x)
图自己画
core = [1 2 3 5 7 9 13 14 15]
n = _ core core
n = length (core)
n (1) = _ core 将第一个元素移除% []
_ core (n) = n (n)% 最后一元素与mag最后一元素相同 core
_ = n _ del core core core 求二者之差%