MATLAB学习
>> clear
>> clear all
>> load chirp
>> Fs
Fs =
8192
>> plot(y)
>> figure
>> plot(y)
>> Y=fft(y)
>> plot(abs(Y))
>>> specgram(y)
specgram函数结果
中国锣
>> load gong
>> sound(y,Fs)
>>> hndlgraf
在微型窗口中
x = 0:0.02:1;
hndl = plot(x,humps(x));
set(hndl,'Color','red')
set(hndl,'Marker','x')
set(hndl,'LineWidth',2)
set(hndl,'Color','red')
>> hndlaxis
微型窗口中
x = logspace(-2,0,500);
plot(x,((sin(1./x)).^2)./x);
set(gca,'XGrid','on','YGrid','on');
set(gca,'XScale','log','YScale','linear');
xpbombs小游戏
>>sound(mtlb*0.01,Fs)
>> sound(mtlb,Fs)
>> sound(mtlb*0.5,Fs)
可通过乘以数来改变音量
编程基础
2.1变量
对复数的处理
real
imag
angle
abs
复数的极坐标输入
z3=25*exp(i*pi*3)
对矩阵的处理
>> f1=[1,2,3]
f1 =
1 2 3
>> f2=[f1 f1 f1]
f2 =
1 2 3 1 2 3 1 2 3
>> f3=[f1;f1;f1]
f3 =
1 2 3
1 2 3
1 2 3
>> f4=[f3 f3';f3 fliplr(f3)]
f4 =
1 2 3 1 1 1
1 2 3 2 2 2
1 2 3 3 3 3
1 2 3 3 2 1
1 2 3 3 2 1
1 2 3 3 2 1
>> noise=rand(1,10000);
>> sum(noise)/length(noise)
ans =
0.4994
>> plot(noise(1:100))
>> hist(noise)
>> noise=randn(1,10000);
>> hist(noise)
>> hist(noise,100)
>> eye(5)
>> linspace(0,1,11)
>> logspace(0,1,10)
>> stem(ans)
矩阵的运算
1.' \\矩阵转置
2.fliplr(a) 左右翻转
3.flipud(a) 上下翻转
4.rot90(a) 逆时针90度
5.diag(a) 取对角线
6.tril(a) 上三角
7.reshape(a,1,9) 矩阵变维度
exp
exp(1:5)
sqrt
pow2(3)幂函数
nextpow2
log log10 log2
isreal函数 判断是否实数
t=0:0.001:7
x=2*atan(tan(t));
plot(t,x,'b')
hold on
phase=unwrap(x)
plot(t,phase,'r:')
round四舍五入
fix
floor
ceil 向上取整
sign(0.1)符号函数
rem除后的余数