?? vceng1view.cpp
字號:
// VCeng1View.cpp : implementation of the CVCeng1View class
//
#include "stdafx.h"
#include "VCeng1.h"
#include "VCeng1Doc.h"
#include "VCeng1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View
IMPLEMENT_DYNCREATE(CVCeng1View, CView)
BEGIN_MESSAGE_MAP(CVCeng1View, CView)
//{{AFX_MSG_MAP(CVCeng1View)
ON_COMMAND(ID_Menu_VCeng1, OnMenuVCeng1)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View construction/destruction
CVCeng1View::CVCeng1View()
{
// TODO: add construction code here
}
CVCeng1View::~CVCeng1View()
{
}
BOOL CVCeng1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View drawing
void CVCeng1View::OnDraw(CDC* pDC)
{
CVCeng1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View printing
BOOL CVCeng1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CVCeng1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CVCeng1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View diagnostics
#ifdef _DEBUG
void CVCeng1View::AssertValid() const
{
CView::AssertValid();
}
void CVCeng1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CVCeng1Doc* CVCeng1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVCeng1Doc)));
return (CVCeng1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVCeng1View message handlers
void CVCeng1View::OnMenuVCeng1()
{
Engine *ep; ///////////引擎對象指針聲明
double t[1];
t[0]=6.28;
mxArray *T=NULL;
if(!(ep=engOpen(NULL)))//////////打開引擎
{ AfxMessageBox("Can not open the matlab engine!"); exit(-1);}
T=mxCreateDoubleMatrix(1,1,mxREAL);
memcpy((char*)mxGetPr(T),(char*)t,1*sizeof(double));
///////////////////////通過引擎庫函數調用matlab命令
engPutVariable(ep,"ep_T",T);
engEvalString(ep,"ep_T1=0:pi/48:ep_T;");
engEvalString(ep,"ep_D=sin(ep_T1)");
engEvalString(ep,"plot(ep_T1,ep_D,'r-');");
engEvalString(ep,"xlabel('t');");
engEvalString(ep,"ylabel('sin(t)');");
engEvalString(ep,"title('sin(x) curve');");
AfxMessageBox("關閉引擎");
engClose(ep); //////////關閉引擎
mxDestroyArray(T); ///////內存釋放
}
/////////////////結束
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -