?? exm12033_1.cpp
字號:
#include "engine.h"
#include "mat.h"
#include <iostream.h>
#include <windows.h>
#include <stdlib.h>
#include <iomanip.h>
void main()
{
double * b,a[9]={1,4,7,2,5,8,3,6,9};
const char *file="mymat.mat";
mxArray *Ain,*Aout,*SV;
Engine * ep;
MATFile *mat;
mat=matOpen(file,"w");
Ain = mxCreateDoubleMatrix(3,3,mxREAL);
mxSetClassName(Ain,"z");
memcpy((char *)mxGetPr(Ain),(char *)a,9*sizeof(double));
matPutVariable(mat,"z",Ain);
matClose(mat);
mxDestroyArray(Ain);
mat=matOpen(file,"r");
Aout =matGetVariable(mat,"z");
if(ep=engOpen(NULL))
{
engPutVariable(ep,"z",Aout);
engEvalString(ep,"sv=svd(z);");
SV=engGetVariable(ep,"sv");
b=mxGetPr(SV);
cout<<"奇異值為";
cout<<"\n";
for(int i=0;i<3;i++)
{
cout<<setw(16)<<b[i];
}
engClose(ep);
matClose(mat);
mxDestroyArray(Aout);
mxDestroyArray(SV);
}
else
cout<<"Can't open matlab";
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -