⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_gsmmodulation.c

📁 基于MATLAB的GSM仿真系统 并附有直接画出性能曲线的简化程序。
💻 C
字号:
#include "test_GSMMOdulation.h"

int  DebugGSMRotation(double inArray[2][BURSTLEN*OVERSAMPLE],
                      double outArray[2][BURSTLEN*OVERSAMPLE],int init)
{
	int i,j,jCount;
	
	jCount = init+1;
	for (i = 0;i<BURSTLEN;i++)
	{
		for (j = 0;j<4;j++)
		{
			switch (jCount)
			{
				case 0:
				outArray[0][i*OVERSAMPLE+j] = inArray[0][i*OVERSAMPLE+j];
				outArray[1][i*OVERSAMPLE+j] = inArray[1][i*OVERSAMPLE+j];
				break;
				
				case 1:
				outArray[0][i*OVERSAMPLE+j] = -inArray[1][i*OVERSAMPLE+j];
				outArray[1][i*OVERSAMPLE+j] = inArray[0][i*OVERSAMPLE+j];
				break;
				
				case 2:
				outArray[0][i*OVERSAMPLE+j] = -inArray[0][i*OVERSAMPLE+j];
				outArray[1][i*OVERSAMPLE+j] = -inArray[1][i*OVERSAMPLE+j];
				break;
				
				case 3:
				outArray[0][i*OVERSAMPLE+j] = inArray[1][i*OVERSAMPLE+j];
				outArray[1][i*OVERSAMPLE+j] = -inArray[0][i*OVERSAMPLE+j];
				break;
				
				default:
				printf("Invalid Case in Rotation.\n");
				while(1)
				{
					//Sleep(2);
				}
				break;
			}
		}
		jCount = (jCount+1)%4;
	}
	return 0;
}


int  DebugGSMGMSK(double inArray[2][BURSTLEN*OVERSAMPLE],double outArray[2][BURSTLEN*OVERSAMPLE])
{
	int i,j;
	double sampleTable[]={0.0007,0.0061,0.0315,0.1076,0.2605,0.4789,0.7057,0.8692,0.9268,
	                      0.8692,0.7057,0.4789,0.2605,0.1076,0.0315,0.0061,0.0007};
	double tempArray[2][(BURSTLEN+3)*OVERSAMPLE];
	double tempAmp,tempAmp1;
	
	//Initialise
	//Add 3 0s to the head of inArray
	for (i = 0;i<4;i++)
	{
		tempArray[0][i] = -1.0;
		tempArray[1][i] = 0.0;
	}
	for (i = 0;i<4;i++)
	{
		tempArray[0][i+4] = 0.0;
		tempArray[1][i+4] = -1.0;
	}
	for (i = 0;i<4;i++)
	{
		tempArray[0][i+8] = 1.0;
		tempArray[1][i+8] = 0.0;
	}
	for (i = 3;i<(BURSTLEN+3);i++)
	{
		for (j = 0;j<OVERSAMPLE;j++)
		{
			tempArray[0][i*OVERSAMPLE+j] = inArray[0][(i-3)*OVERSAMPLE+j];
			tempArray[1][i*OVERSAMPLE+j] = inArray[1][(i-3)*OVERSAMPLE+j];
		}
	}
	
	//GMSK (Approximation)
	for (i = 3;i<(BURSTLEN+3);i++)
	{
		for (j = 0;j<OVERSAMPLE;j++)
		{
			outArray[0][(i-3)*OVERSAMPLE+j] = tempArray[0][(i-3)*OVERSAMPLE+j]*sampleTable[12+j]
			                                 +tempArray[0][(i-2)*OVERSAMPLE+j]*sampleTable[8+j]
			                                 +tempArray[0][(i-1)*OVERSAMPLE+j]*sampleTable[4+j]
			                                 +tempArray[0][i*OVERSAMPLE+j]*sampleTable[j];
			outArray[1][(i-3)*OVERSAMPLE+j] = tempArray[1][(i-3)*OVERSAMPLE+j]*sampleTable[12+j]
			                                 +tempArray[1][(i-2)*OVERSAMPLE+j]*sampleTable[8+j]
			                                 +tempArray[1][(i-1)*OVERSAMPLE+j]*sampleTable[4+j]
			                                 +tempArray[1][i*OVERSAMPLE+j]*sampleTable[j];
		}
	}

	//Normalize signal
	for (i=0;i<BURSTLEN;i++)
	{
		for (j=0;j<4;j++)
		{
			tempAmp = outArray[0][i*OVERSAMPLE+j]*outArray[0][i*OVERSAMPLE+j]
				     +outArray[1][i*OVERSAMPLE+j]*outArray[1][i*OVERSAMPLE+j];
			tempAmp1 = 1/tempAmp;
			tempAmp = sqrt(tempAmp1);
			outArray[0][i*OVERSAMPLE+j] = outArray[0][i*OVERSAMPLE+j]*tempAmp;
			outArray[1][i*OVERSAMPLE+j] = outArray[1][i*OVERSAMPLE+j]*tempAmp;
		}
	}

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -