
matlab
谢娘蓝桥
绿水青山境长静,花落虽频意自闲。
展开
-
Biquad 滤波器计算
基础iir 滤波器框图如上x h (n) = x(n) − a 1 x h (n − 1) − a 2 x h (n − 2) y(n) = b 0 x h (n) + b 1 x h (n − 1) + b 2 x h (n − 2) 1.第一种采用Robert Bristow-Johnson 的方法biquad的 传递函数定义为 b0 + b1*z^-1 + b2*z^-2 H(z) = ------------------------...原创 2022-03-14 23:19:00 · 4697 阅读 · 6 评论 -
matlab 生成正弦波
function s = mysin(amp,freq,phase,dur, samp_freq)% example function to so show how amplitude,frequency and phase% are changed in a sin function% Inputs: amp - amplitude of the wave% freq - frequency of the wave% phase - phase of the wave in degree% .原创 2021-11-12 17:21:31 · 2774 阅读 · 0 评论 -
matlab实现音频瀑布图
function waterfallspect(s, fs, spectsize, spectnum)%WATERFALLSPECT Display spectrum of signal s as a 3-D plot.% s - input signal, use wavload to load a WAV file% fs - Sampling frequency (Hz).% spectsize - FFT window size% spectnum - number of.原创 2020-10-10 15:33:30 · 2590 阅读 · 0 评论 -
matlab音频频谱实现
function plot_amp_spectrum(Fs, y, varargin)%PLOT_AMP_SPECTRUM Plot amplitude spectrum of a one dimensional signal% PLOT_AMP_SPECTRUM(FS, Y, COLOR, SEMILOG_SCALE, TITLE_STRING) plots the% amplitude spectrum of y which has sampling frency Fs. Specific原创 2020-08-15 14:18:17 · 1329 阅读 · 0 评论 -
头文件保存matlab数据
% This program is useful to convert numbers in MATLAB's Double% format to a text file in float format for C compilers% You should copy the resulting text to a file and save it with .h% extension% THIS PROGRAM RECEIVES AN UNIDIMENTIONAL VECTOR OF DOUB原创 2020-08-15 13:57:39 · 522 阅读 · 0 评论 -
音频能量计算
音频能量计算function [y] = pow_1(x)N = length(x); % Length of voice signal 'x'xold =0.0; %initialize it to zerofor n = 1:N sumx = xold+(x(n)^2); xold = sumx;endy = sumx/N原创 2020-08-15 13:51:56 · 2760 阅读 · 0 评论 -
A/C加权的matlab实现
A加权%Sampling RateFs = 48000;%Analog A-weighting filter according to IEC/CD 1672.f1 = 20.598997; f2 = 107.65265;f3 = 737.86223;f4 = 12194.217;A1000 = 1.9997;pi = 3.14159265358979;NUM = [ (2*pi*f4)^2*(10^(A1000/20)) 0 0 0 0 ];DEN = conv([1 +4*p原创 2020-08-10 15:52:50 · 1768 阅读 · 0 评论 -
粉红噪声matlab产生
function out = create_pink_noise(Fs, Sec, Amp)% Creates a pink noise signal and saves it as a wav file%% Usage: create_noise(Fs, Sec, Amp);%% Fs is the desired sampling rate% Sec is the duration of the signal in seconds% Amp i.原创 2020-08-10 15:50:47 · 7427 阅读 · 11 评论 -
Peak_to_Peak 计算
function y = peak2peak(signal)% Return the peak-to-peak amplitude of the supplied signal. This is the% same as max(signal) minus min(signal).%% Usage: y = PEAK2PEAK(signal);%% SIGNAL is your one-dimensional input array%% Author: sparafucil.原创 2020-08-10 15:48:54 · 1842 阅读 · 0 评论 -
用length和cutoff频率产生fir滤波器
//Design of FIR Filter using Frquency Sampling Technique//Low Pass Filter Design//Cutoff Frequency Wc = pi/2//M = Filter Lenth = 7clear;clc;M = 7;N = ((M-1)/2)+1wc = %pi/2;for k =1:M w(k) = ((2*%pi)/M)*(k-1); if (w(k)>=wc) k-1 bre.原创 2020-08-10 15:45:41 · 316 阅读 · 0 评论 -
NMLS 自适应滤波器matlab实现
%Normalized Least Mean Square Adaptive Filter%for Echo Cancellationfunction [e,h,t] = adapt_filt_nlms(x,B,h,delta,l,l1)%x = the signal from the speaker %B = signal through echo path%h = impulse response of adaptive filter%l = length of the signal x.原创 2020-07-24 16:22:33 · 886 阅读 · 0 评论 -
拉格朗日多项式--重采样
% Lagrange interpolation for resampling% References:% [1] A digital signal processing approach to Interpolation% Ronald W. Schafer and Lawrence R. Rabiner% Proc. IEEE vol 61, pp.692-702, June 1973% [2] https://ccrma.stanford.edu/~jos/Interpol.原创 2020-07-24 15:15:51 · 789 阅读 · 0 评论 -
FARROW 重采样 matlab 实现
% **************************************************************% Vectorized Farrow resampler% M. Nentwig, 2011% Note: Uses cyclic signals (wraps around)% **************************************************************close all; clear all;% inData c.原创 2020-07-24 15:14:00 · 2129 阅读 · 11 评论 -
shelving filter matlab 实现
function [b, a] = shelving(G, fc, fs, Q, type)%% Derive coefficients for a shelving filter with a given amplitude and% cutoff frequency. All coefficients are calculated as described in % Zolzer's DAFX book (p. 50 -55). %% Usage: [B,A] = shel.原创 2020-07-24 14:46:49 · 1020 阅读 · 2 评论 -
LMS 语音消噪
//Caption: Speech Noise Cancellation using LMS Adaptive Filterclc;//Reading a speech signal[x,Fs,bits]=wavread("E:\4.wav");order = 40; // Adaptive filter orderx = x';N = length(x);t = 1:N;//Plot the speech signalfigure(1)subplot(2,1,1)plot(t,.原创 2020-07-24 14:39:23 · 291 阅读 · 0 评论 -
phase changing filter matlab 实现
function [b,a] = allpass(order, Fc, Fs, Q)% Returns allpass filter coefficients.% Currently only 1st and 2nd orders are supported.%% Usage: [b,a] = ALLPASS(N, FC, FS, Q);%% N is the order of the allpass% FC is the frequency a the 90de.原创 2020-07-24 14:37:59 · 190 阅读 · 0 评论 -
计算一个数的n次方跟
function [nth_Roots] = roots_nth(Num, n, Plot)% ROOTS_NTH computes the nth roots of Num.%% Inputs:% Num is the number(s) for which the nth roots will be computed.% Num can be real-valued or complex-valued.% If Num has more than one element.原创 2020-07-24 14:30:06 · 308 阅读 · 0 评论 -
matlab filter designer 参数提取
平常设计测试滤波器参数,都要从matlab中导出来,matlab导出的参数默认是科学计数法的(双精度),所以写段代码进行转换clear all;clc;%FIR 参数提取data = importdata('fdacoefs256.h');%%%长度 Taps = order +1;Len = 256;const = data.data;fid = fopen('l...原创 2019-11-22 16:36:39 · 2618 阅读 · 0 评论 -
基于eigen 实现mfcc提取特征矩阵的实现
MatrixXd mfcc_m(double *x, int length, int fs, int p, int framesize, int inc){ MatrixXd bank = melbankm(p, framesize, fs, 0, 0.5, 1); //bank.operator/=(splab::max(splab::max(bank))); bank = bank ...原创 2018-11-09 13:38:04 · 760 阅读 · 0 评论 -
基于SP++ mel滤波器组实现
//win_type =0 w=='n' 汉宁窗 win_type =1 w=='m'汉明窗Matrix<Type> melbankm(Type p, Type n, Type fs, Type fl, Type fh, int win_type){ Vector<Type>mflh(2); mflh(1) = fl*fs; mflh(2) = fh*f...原创 2018-10-17 14:35:25 · 811 阅读 · 0 评论 -
基于SP++ mel频率倒谱系数
感知频率和实际频率转换函数Vector<Type>frq2mel(Vector<Type> frq){ Type k = 1127.01048; Vector<Type> af(frq.size(), abs(frq)); Vector<Type> mel(frq.size(), sign(frq)*log((Typ...原创 2018-10-17 13:28:05 · 287 阅读 · 0 评论 -
基于sp++ matlab sign 符合函数实现
sign(整数)=1; sign(负数)=-1; sign(零)=0; 向量版Vector<Type>sign(Vector<Type> a){ Vector<Type> p(a.size()); for (int i = 0; i < a.size(); i++) { if (a[i] > 0)...原创 2018-10-17 13:25:41 · 522 阅读 · 0 评论 -
基于sp++ 实现matlab cov 函数
// 向量的方差Type cov(Vector<Type> x){ Type x_mean = sum(x) / x.size(); Type x_std = sum(pow(x - x_mean, (Type)2)) / (x.size() - 1); return x_std;}//两向量的协方差Matrix<Type>cov_Matrix(Vecto...原创 2018-10-19 17:24:59 · 516 阅读 · 0 评论 -
基于 sp++ 简单的声纹比对
//声纹识别Type nonfilter_speccor(Type*x1, Type*x2, int length, int fs){ Matrix<Type>Cn1 = mfcc_m(x1, length, fs,24 ,1024, 512); Cn1 = mapminmax(Cn1, -1, 1); Matrix<Type>Cn2 = mfcc_m(x2, ...原创 2018-10-19 17:08:44 · 1855 阅读 · 1 评论 -
基于sp++ 实现matlab corr corrcoef函数 计算皮尔逊相关系数
参考概念https://blog.youkuaiyun.com/crcr/article/details/58594432?utm_source=blogxgwz0用最简单的公式4可以实现下面代码。//皮尔逊相关系数计算Type myPearson(Vector<Type>x, Vector<Type>y){ Type A = sum(x*y) - (sum(x...原创 2018-10-19 11:27:11 · 1258 阅读 · 0 评论 -
基于sp++实现 [ 0 1 ]归一化 [-1 1] 归一化(matlab mapminmax 函数的实现)
matlab中归一的算法:y =(ymax-ymin)*(x-xmin)/(xmax-xmin)+ ymin; 简化到[0 1]即为y =(x-min(x))/(max(x)-min(x));基于SP ++实现过程如下: //归一化函数 x 输入向量 ymin 输出最小值 ymax 输出最大值Vector<Type>mapminmax(Vector<Ty...原创 2018-10-19 09:52:35 · 1955 阅读 · 0 评论 -
基于sp++ matlab enframe c++ 实现
调用的SP++ 矩阵运算的库。下载地址https://www.oschina.net/p/tspl 1.带窗参数版本 //C++实现enframe分帧函数//输入://float* data:信号源(行向量)//datalength data长度//win 窗函数参数//winlength:每一帧的长度//hop:一帧与一帧之间移动的样点数,有的称为非重叠的长度...原创 2018-09-18 19:00:36 · 496 阅读 · 0 评论 -
基于sp++ matlab mfcc 特征提取 c /c ++ 实现
//mel 滤波器函数//x 输入序列 fs采样率 p滤波器个数 framesize 帧大小 inc 帧移//提取mel滤波器参数用汉明窗函数Matrix<Type> mfcc_m(double *x, int length,int fs, int p, int framesize, int inc){ Matrix<Type> bank = melban...原创 2018-10-18 20:51:03 · 494 阅读 · 0 评论 -
基于 eigen matlab mapminmax 函数的实现
//归一化函数 x 输入向量 ymin 输出最小值 ymax 输出最大值VectorXd mapminmax(VectorXd x, Type ymin =-1, Type ymax=1){ VectorXd y(x.size()) ; if ((x.maxCoeff() <= ymax) && (x.minCoeff() >= ymin)) { y...原创 2018-11-09 13:45:00 · 469 阅读 · 0 评论 -
matlab 存储变量成txt数组,方便嵌入式调用
fid=fopen('bad_mic_frame.txt','w');fprintf(fid,"float mic_frame[%d]={",M*Frame_len);for i=1:M*Frame_len-1 fprintf(fid,'%.12f ,',single_frame(i));endfprintf(fid,"%.12f };\n",single_frame(M*Fra...原创 2018-11-07 11:22:08 · 1421 阅读 · 0 评论 -
matlab 简单神经网络 sim 自主实现
function y = MyBPSim(net,Test_data,inputps) %Test_data,待分类的数据,每行表示一个特征向量 IW = net.IW{1,1}; % net是训练得到的网络,IW表示隐含层的权矩阵 % 维数 = 隐含层神经元个数 * 特征数 LW = net.LW{2,1}; % LW表...原创 2018-11-13 19:55:15 · 6845 阅读 · 0 评论 -
matlab 计算过零率
function count = zero_crossings(x)% x 必须是1位的行向量或者列向量 时域信号% count为返回的过零率计算% initial valuecount = 0;% error checksif(length(x) == 1) error('ERROR: input signal must have more than one eleme...原创 2019-07-26 15:35:16 · 3710 阅读 · 0 评论 -
mfcc 特征标准获取
function mfcc_coe=mfcc_standard(x,fs,p,frameSize,inc)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function mfcc_coe=mfcc_standard(x,fs,p,frameSize,inc)%对输入的语音序列x进行MFCC参数的提取,返回MFCC参数和一阶%差分MFCC参数,Mel滤...原创 2019-07-16 17:40:33 · 637 阅读 · 0 评论 -
matlab 根据按键移动文件到不同文件夹
%% 播放文件,标定数据clc;close all;clear;N=6000;pause(2);SOURCE_PATH_t = 'E:\Users\li\Desktop\算法\sound\';%源目录文件夹DST_PATH_t1 = 'E:\Users\li\Desktop\算法\have_car1\';%目的文件目录 DST_PATH_t2 = 'E:\Users\li\Deskt...原创 2019-03-28 15:55:07 · 333 阅读 · 0 评论 -
基于rbf核SVM C++ 实现
//svm rbf核函数 rbf_sigma 不能为0MatrixXd SVM_rbf(MatrixXd u, MatrixXd v, double rbf_sigma=1){ double sigma = -1 / (pow(rbf_sigma, 2) * 2); MatrixXd tmp = u.array().square().rowwise().sum().square().s...原创 2019-01-11 10:42:49 · 954 阅读 · 0 评论 -
基于自相关法检测噪声中周期性函数
1.前提认为噪声为加性噪声,噪声自相关在m=0时为固定值,m≠0时为0;周期信号的自相关函数,仍是周期函数,并且周期和原函数周期相同白噪声和周期信号完全不相关,白噪声的完全随机性导致它和任何函数都不相关恋。它们之间的互相关函数可认为是零fs = 5e3;n = 0:1/fs:1;len = length(n);freq = 100;s = sin(2*pi*freq*n)...原创 2018-12-24 16:59:27 · 4140 阅读 · 0 评论 -
基于Eigen 实现 matlab fftshift
啥也不说 上代码 cirshift 见以前的文章/*Fun: fftshiftauthor:christime:2018//11/30input:x :输入矩阵Input dim 0,按x总数下移位一半1,下移动总行数的的一半,右移一次2,下移栋总列数的一半,右移动2次大于2时,右移动 dim次*/MatrixXd fftshift(MatrixXd x, int d...原创 2018-11-30 10:51:39 · 1173 阅读 · 0 评论 -
mls 伪随机噪声
function y = mls(n,flag)%y = mls(n,{flag});%%Generates a Maximum Length Sequence of n bits by utilizing a %linear feedback shift register with an XOR gate on the tap bits %%Function can accep...原创 2018-11-29 11:58:05 · 898 阅读 · 1 评论 -
emd 函数 matlab 中文备注
% EMD 计算经验模式分解%%% 语法%%% IMF = EMD(X)% IMF = EMD(X,...,'Option_name',Option_value,...)% IMF = EMD(X,OPTS)% [IMF,ORT,NB_ITERATIONS] = EMD(...)%%% 描述%%% IMF = EMD(X) X是一个实矢量,计算方法参考[1]...原创 2018-11-20 19:22:29 · 10043 阅读 · 19 评论 -
批量修改文件便于matlab输入
1.文件批量重命名@echo offsetlocal enabledelayedexpansionfor %%x in (*) do ( if not "%%x"=="demo.bat" ( set /a sum+=1 rename "%%x" "!sum!.txt" ))echo 批量重命名完成!pause新建一个demo...原创 2018-11-15 14:15:56 · 528 阅读 · 0 评论