NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
westernwater
Posts: 2
0 Kudos

CNiGraph display distortion

Hi, I want to use matlab and c++ to display sine curve severally. In c++ code, I use CNiGraph to display the curve, and below is the outcome:

c++

but, the real curve in matlab is:

matlab

I really want to know why. Please help me. Thanks.

c++ code:

void CmychirpDlg::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	if (!libmychirpInitialize() )
		{

		}
	try
		{
			double *x=new double[5501];
			double *t=new double[5501];
			for (int i=0;i<5501;i++)
				t[i]=1+i/500;
			double f0=1;
			double t1=1;
			double f1=1;
			mwArray T(1, 5501, mxDOUBLE_CLASS);
			mwArray F0(1, 1, mxDOUBLE_CLASS);
			mwArray T1(1, 1, mxDOUBLE_CLASS);
			mwArray F1(1, 1, mxDOUBLE_CLASS);
			mwArray X(1,5501,mxDOUBLE_CLASS);
			T.SetData(t,5501);
			F0.SetData(&f0,1);
			T1.SetData(&t1,1);
			F1.SetData(&f1,1);
			mychirp(1,X,T,F0,T1,F1);
			X.GetData(x,5501);
			
			m_Graphmychirp.PlotXvsY(CNiReal64Vector(5501,t),CNiReal64Matrix(1,5501,x));
			delete []x;
			x=NULL;
			delete []t;
			t=NULL;
			
		 }//try;     
		
		catch(const mwException& e)
		{
			MessageBox(e.what());
		}
        
		catch(...)
		{
			MessageBox("Unexpected error thrown");
		}

}

 


By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page