原创 Labwindows/cvi8.5学习日志(40)----白噪声

2010-7-29 10:52 3508 7 8 分类: 软件与OS

accefa14-0572-486a-b18f-e50fc643f91f.jpg


//*****************************************************************************
// Labwindows/cvi8.5 白噪声发生器 
// szlihongtao      
// 2010-07-29
//*****************************************************************************  
#include <userint.h>
#include <ansi_c.h>
#include <analysis.h>
#include <cvirte.h>
#include <userint.h>
#include "t.h"
//*****************************************************************************
static int panelHandle;


double amp;
unsigned int cnt;
double seed;
double *wave;
//*****************************************************************************
int main (int argc, char *argv[])
{
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1; /* out of memory */
 if ((panelHandle = LoadPanel (0, "t.uir", PANEL)) < 0)
  return -1;
 DisplayPanel (panelHandle);
 RunUserInterface ();
 DiscardPanel (panelHandle);
 return 0;
}
//*****************************************************************************
int CVICALLBACK GenerateWave (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:           
  {
   GetCtrlVal (panelHandle, PANEL_AMP, &amp);
   GetCtrlVal (panelHandle, PANEL_SEED, &seed);
   GetCtrlVal (panelHandle, PANEL_NUM, &cnt);
   wave=malloc(cnt*sizeof(double));   // 申请内存
   WhiteNoise (cnt, amp, seed, wave);   // 产生白噪声


   DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_IMMEDIATE_DRAW);
   PlotY (panelHandle, PANEL_GRAPH, wave, cnt, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
   free(wave);  // 释放内存


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


 

PARTNER CONTENT

文章评论1条评论)

登录后参与讨论

用户377235 2013-1-30 17:40

我是新学者,为什么我编译成功,在界面输入三个参数后,生成白噪声出错,显示NON-FATAL RUN-TIME ERROR: "baizaos.c", line 40, col 14, thread id 0x00001398: Library function error (return value == -10 [0xfffffff6]). The control is not the type expected by the function ?求指教。谢谢。
相关推荐阅读
sz_lihongtao 2011-04-20 21:32
32bit无符号数快速开平方根
//*******************************************************************************// 32bit无符号数开平方根// ...
sz_lihongtao 2011-04-20 12:12
STM32学习日志(24)----使用dsp库的FFT函数测相位
attachment download/**  ****************************************************************************...
sz_lihongtao 2011-04-19 14:57
STM32学习日志(23)----使用dsp库的FFT函数.rar
attachment download/**  ****************************************************************************...
sz_lihongtao 2011-04-19 10:39
stm32 dsp lib V2.0
attachment downloadattachment download...
sz_lihongtao 2011-04-19 10:37
STM32学习日志(22)----使用DMA功能自动更新PWM的输出
attachment download/*******************************************************************************编...
sz_lihongtao 2010-09-08 21:59
Labwindows/cvi8.5学习日志(56)----任意波形发生器
//******************************************************************************// Labwindows/cvi8.5...
EE直播间
更多
我要评论
1
7
关闭 站长推荐上一条 /3 下一条