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

📄 unit1.cpp

📁 调用matlab详细程序 调用matlab详细程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#include"Engine.h"
#pragma hdrstop
#include<math.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TEdit *Edi[8];

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double *b,a[2][4]={{2,5,4,3},{3,4,5,6}};
 double *c;
  mxArray *z,*x1=NULL;
  Engine *ep;
   z=mxCreateDoubleMatrix(2,4,mxREAL);
   //mxSetClassName(z,"z");
   if(ep=engOpen(NULL))
   {
    memcpy((char*)mxGetPr(z),(char*)a,2*4*sizeof(double));
   engPutVariable(ep,"z",z);
   engEvalString(ep,"x=z;");
    x1=engGetVariable(ep,"x");
    c=mxGetPr(x1);
   }
   else ShowMessage("Can't Open The Engine!");
   engClose(ep);
   for(int i=0;i<8;i++)
   {
   Edi[i]=new TEdit(this);
   Edi[i]->Text=c[i];
   Edi[i]->Parent=Form1;
   Edi[i]->Visible=true;
   Edi[i]->Left=40;
   Edi[i]->Top=50+i*40;
   Edi[i]->Height=21;
   Edi[i]->Show();
   }

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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