最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用C++ Matlab中的lp2lp函數(shù)教程詳解

 更新時(shí)間:2023年04月22日 10:36:37   作者:胡剛2016  
本文介紹如何使用C++編寫(xiě)數(shù)字濾波器設(shè)計(jì)算法,實(shí)現(xiàn)Matlab中的lp2lp函數(shù),將低通濾波器轉(zhuǎn)換為參數(shù)化的低通濾波器,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧

1. matlab的lp2lp函數(shù)的作用

去歸一化 H(s) 的分母

2. matlab的lp2lp函數(shù)的使用方法

[z, p, k]=buttap(3);
disp("零點(diǎn):"+z);
disp("極點(diǎn):"+p);
disp("增益:"+k);
[Bap,Aap]=zp2tf(z,p,k);% 由零極點(diǎn)和增益確定歸一化Han(s)系數(shù)
disp("Bap="+Bap);
disp("Aap="+Aap);
[Bbs,Abs]=lp2lp(Bap,Aap,86.178823974858318);% 低通到低通 計(jì)算去歸一化Ha(s),最后一個(gè)參數(shù)就是去歸一化的 截止頻率
disp("Bbs="+Bbs);
disp("Abs="+Abs);

3. C++ 實(shí)現(xiàn)

3.1 complex.h 文件

#pragma once
#include <iostream>
typedef struct Complex
{
	double real;// 實(shí)數(shù)
	double img;// 虛數(shù)
	Complex()
	{
		real = 0.0;
		img = 0.0;
	}
	Complex(double r, double i)
	{
		real = r;
		img = i;
	}
}Complex;
/*復(fù)數(shù)乘法*/
int complex_mul(Complex* input_1, Complex* input_2, Complex* output)
{
	if (input_1 == NULL || input_2 == NULL || output == NULL)
	{
		std::cout << "complex_mul error!" << std::endl;
		return -1;
	}
	output->real = input_1->real * input_2->real - input_1->img * input_2->img;
	output->img = input_1->real * input_2->img + input_1->img * input_2->real;
	return 0;
}

3.2 lp2lp.h 文件

實(shí)現(xiàn)方法很簡(jiǎn)單,將 H(s) 的分母的系數(shù)乘以 pow(wc, 這一項(xiàng)的指數(shù)) 即可

#pragma once
#include <iostream>
#include <vector>
#include <algorithm>
#include "complex.h"
using namespace std;
vector<pair<Complex*, int>> lp2lp(vector<pair<Complex*, int>> tf, double wc)
{
	vector<pair<Complex*, int>> result;
	if (tf.size() <= 0 || wc <= 0.001)
	{
		return result;
	}
	result.resize(tf.size());
	for (int i = 0; i < tf.size(); i++)
	{
		double coeff = pow(wc, tf[i].second);
		Complex* c = (Complex*)malloc(sizeof(Complex));
		c->real = coeff * tf[i].first->real;
		c->img = coeff * tf[i].first->img;
		pair<Complex*, int> p(c, tf[i].second);
		result[i] = p;
	}
	return result;
}

4. 測(cè)試結(jié)果

4.1 測(cè)試文件

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include "buttap.h"
#include "zp2tf.h"
#include "lp2lp.h"
using namespace std;
#define pi ((double)3.141592653589793)
int main()
{
	vector<Complex*> poles = buttap(3);
	vector<pair<Complex*, int>> tf = zp2tf(poles);
	// 去歸一化后的 H(s) 的分母
	vector<pair<Complex*, int>> ap = lp2lp(tf, 86.178823974858318);
	return 0;
}

4.2 測(cè)試3階的情況

4.3 測(cè)試9階的情況

可以看出二者結(jié)果一樣,大家可以自行驗(yàn)證

到此這篇關(guān)于使用C++ Matlab中的lp2lp函數(shù)教程詳解的文章就介紹到這了,更多相關(guān)C++ Matlab中的lp2lp函數(shù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

钟山县| 安徽省| 吴江市| 和顺县| 苏尼特左旗| 沾化县| 宁远县| 台东市| 张家港市| 祁连县| 合作市| 东台市| 综艺| 泸溪县| 田阳县| 中卫市| 舟山市| 乌拉特中旗| 温泉县| 夏津县| 任丘市| 嵊州市| 博乐市| 威远县| 罗源县| 安多县| 屏山县| 阜康市| 灵台县| 咸丰县| 神农架林区| 镇赉县| 丰都县| 佛坪县| 河间市| 美姑县| 凭祥市| 临泉县| 周口市| 潞西市| 保定市|