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

📄 gz10.c

📁 虚拟小波消噪仪,有程序的形式实现消噪的功能
💻 C
字号:
#include <cvirte.h>		
#include <userint.h>
#include "GZ10.h"
#include "d:\Documents and Settings\Administrator\My Documents\GZ\虚拟小波消噪仪\GZ10.h"
#include <cviauto.h>
#include "matlabUtil.h"
#include "matlabsrvr.h"
#include <analysis.h>
#include <ansi_c.h>
#include <utility.h>
#include <formatio.h>



static int panelHandle;


static CAObjHandle hMatlab=0;
double wave[1024],*Noise,*PrimitiveWave;
int i;

int main (int argc, char *argv[])
{
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHandle = LoadPanel (0, "GZ10.uir", Panel)) < 0)
		return -1;
	DisplayPanel (panelHandle);
	RunUserInterface ();
	DiscardPanel (panelHandle);
	return 0;
}

int CVICALLBACK ExecuteFilter (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
HRESULT stat;
double result=0;
double *matrixReal=NULL;
double *matrixImag=NULL;
unsigned dim1=2;
unsigned dim2=2;
double a[1024];

	switch (event)
		{
		case EVENT_COMMIT:
		stat=MLApp_NewDIMLApp (NULL, 1, LOCALE_NEUTRAL, 0, &hMatlab);
		MinMaxMatlab(hMatlab,0);
		for(i=0;i<1024;i++)
		a[i]=wave[i];
		result=SendMatrix(hMatlab,"xx",(double *)a,NULL,1,1024);
		if(result!=SUCCESS)
		{
		MessagePopup("ERROR","Error in sending Matrix to MATLAB");
		return 0; 
		}
		
		result=RunMatlabCommand(hMatlab,"xd=wden(xx,'heursure','s','one',8,'sym8');");
		if (result!=SUCCESS)
		{
		MessagePopup("ERROR","Error in sending command to MATLAB"); 
		return 0;
		}
		result=GetMatrix(hMatlab,"xd",&matrixReal,&matrixImag,&dim1,&dim2);
		if(result!=SUCCESS)
		{
		MessagePopup("ERROR","Error in Getting Matrix from MATLAB");
		return 0;
		}
		DeleteGraphPlot(panelHandle,Panel_FilGRAGH,-1,VAL_IMMEDIATE_DRAW);
		PlotY(panelHandle,Panel_FilGRAGH,matrixReal,1024,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,VAL_RED);


			break;
		}
	return 0;
}

int CVICALLBACK DispPrimitGRAGH (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2) 
{
    
    
    double phase,f;
    
	switch (event)
		{
		case EVENT_COMMIT:
		phase=0;
		f=1.0/256;
		Noise=malloc(1024*sizeof(double));
		WhiteNoise(1024,1,1,Noise);
		PrimitiveWave=malloc(1024*sizeof(double));
		//wave=malloc(1024*sizeof(double));
		SineWave(1024,1,f,&phase,PrimitiveWave);
		for (i=0;i<1024;i++)
		wave[i]=Noise[i]+PrimitiveWave[i];
		DeleteGraphPlot(panelHandle,Panel_PriGRAPH,-1,VAL_IMMEDIATE_DRAW);
		PlotY(panelHandle,Panel_PriGRAPH,wave,1024,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,VAL_RED);
		

			break;
		}
	return 0;
}

int CVICALLBACK Close (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
		{
		case EVENT_COMMIT:
			QuitUserInterface (0);
			break;
		}
	return 0;
}

⌨️ 快捷键说明

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