n = [-5:5];
x = [0 0 0 0 0 1 0 0 0 0 0];
% 画序列图,列宽为2
stem(n,x,'linewidth',2);
xlabel('n');
ylabel('x(n)');
x = [1 2 4 2 3];
n = -2:2;
stem(n,x);
xlabel('n');
ylabel('x(n)');
n = 0:10;
x1 = power(0.8,n)
stem(n,x1,'linewidth',2)
xlabel('n');
ylabel('a^n');
axis([n(1) n(end) -1.5 1.5]);
text(7,1,2,'a = 0.8');
n = 0:31;
w0 = pi/8;
x = sin(w0*n);
stem(n,x,'linewidth',2);
xlabel('n');
ylabel('x(n)');
axis([0 max(n) -1.1 1.1]);
N = 11;
n = (0:N-1)';
w = window(@rectwin,N);
stem(n,w,'linewidth',2);
xlabel('n');
ylabel('R_N(n)');
ylim([0 1.5])
clear all;close all;
t0 = 0;
tf = 5;
dt = 0.01;
t = [t0:dt:tf];
alpha = -0.5;
w = 10;
x = exp((alpha+j*w)*t);
subplot(2,2,1);
plot(t,real(x),'linewidth',2)
xlim([t(1) t(end)])
grid on;
xlabel('t');ylabel('real part');
suplot(222);
plot(t,img(x),'linewidth',2)
suplot(223);
plot(t,abs(x),'linewidth',2)
suplot(224);
plot(t,angle(x),'linewidth',2)
x_ang = angle(x);
x_ang_unwrap = unwrap(x_ang)
plot(t,x_ang_unwrap);
grid on;
xlabel('t');ylabel('angle');
t = linspace(-10,10,101);
x = sin(t)./t;
plot(t,x);
% sin(0)./0 Warning:Divided by a zero ans = NaN
t = linspace(-10,10,501);
x = sinc(t/pi);
subplot(211);
plot(t,x);grid on;
xlabel('t');ylabel('Sa(t)'); % 过零点pi的整倍数
y = sinc(t);
subplot(211);
plot(t,y);grid on;
xlabel('t');ylabel('sinc(t)');% 过零点整数
x ( t ) = s i n ( 2 π f 0 t ) x ( n T ) = x ( t ) ∣ t = n T = s i n ( 2 π f 0 n T ) = s i n ( 2 π f 0 n 1 f s ) = s i n ( ω 0 n ) x(t) = sin(2\pi f_0 t) \\ x(nT) = x(t)|_{t=nT} \\ = sin(2\pi f_0nT)=sin(2\pi f_0n\frac{1}{f_s})=sin(\omega_0n) x(t)=sin(2πf0t)x(nT)=x(t)∣t=nT=sin(2πf0nT)=sin(2πf0nfs1)=sin(ω0n)
f0 = 262;
fs = 8192;
omega0 = 2*pi*f0/fs; % 1s数据
n = 0:fs-1;
x = sin(n*omega0);
sound(x,fs);
audiowrite('dou.wav',x,fs);
fs = 8192;
n = 0:fs/2-1
f1 = 262;
f2 = f1*power(2,2/12);
f3 = f1*power(2,4/12);
f4 = f1*power(2,5/12);
f5 = f1*power(2,7/12);
f6 = f1*power(2,9/12);
f7 = f1*power(2,11/12);
fh1 = f1*power(2,11/12);
x1 = sin(n*2*pi*f1/fs);
x2 = sin(n*2*pi*f2/fs);
x3 = sin(n*2*pi*f3/fs);
x4 = sin(n*2*pi*f4/fs);
x5 = sin(n*2*pi*f5/fs);
x6 = sin(n*2*pi*f6/fs);
x7 = sin(n*2*pi*f7/fs);
xh1 = sin(n*2*pi*fh1/fs);
x = [x1 x2 x3 x3 x5 x6 x7 xh1];
sound(x,fs);
% 简单的曲子
y = [x3 x3 x4 x5 x5 x4 x3];
sound(y,fs);
fs = 8000; % fs:抽样频率
Ts = 1/fs; % Ts:抽样间隔
f = 450;% 电话信号音的频率
T = 0.35;% 忙音通和断的时长
t = 0:Ts:T;% 抽样间隔
%电话信号音
x1 = sin(t*2*pi*f);
x2 = zeros(size(x1));
x = [x1 x2];
y = [x x x x];
sound(y,fs);
syms t T;
w = 2*pi/T;
x = sin(w*t);
x1 = subs(x,'T',5);
ezplot(x1,[0 10]);
clear all
syms t T A;
w = 2*pi/T;
x = A*sin(w*t);
M = int(x,0,T)/T % 平均值
P = int(x^2,0,T)/T % 平均功率
x ( t ) = c o s ( 2 π t / T ) s i n ( 2 π t / T ) x(t) = cos(2\pi t/T)sin(2\pi t/T) x(t)=cos(2πt/T)sin(2πt/T)
clear all
syms t T;
A = cos(2*pi*t/T);
B = sin(2*pi*t/T);
x = A*B;
x1 = subs(x,'T',4);
ezplot(x1,[0,4]);
clear all;
syms t;
y1 = exp(-2*t)*cos(3*t)*heaviside(t);
y2 = diff(y1);
y3 = simplify(y2);
x ( t ) = 1 2 [ 1 + c o s ( ω t ) ] [ u ( t + π / ω ) − u ( t − π / ω ) ] x(t)=\frac{1}{2}[1+cos(\omega t)][u(t+\pi/\omega)-u(t-\pi/\omega)] x(t)=21[1+cos(ωt)][u(t+π/ω)−u(t−π/ω)]
clear all;
syms t w;
x = (1+cos(w*t))/2;
E = int(x^2,t,-pi/w,pi/w);
x1 = subs(x,'w',pi);
ezplot(x1,[-1,1]);