VC++绘制天线辐射方向图
4.4.1
时的方向图
4.4.2
4.4.3
时的方向图
时的方向图
VC++绘制天线辐射方向图
4.4.4
4.4.5
4.4.6
时的方向图
时的方向图
时的方向图
VC++绘制天线辐射方向图
第五章 附录
5.1头文件 engine_h
#if defined(_MSC_VER) # pragma once #endif #if
defined(__GNUC__)&&(__GNUC__ >3||(__GNUC__==3&&__GNUC_MINOR__>3)) # pragma once #endif
#ifndef engine_h #define engine_h #ifndef EXTERN_C #ifdef __cplusplus
#define EXTERN_C extern \#else
#define EXTERN_C extern #endif #endif
#include \ /* mx Routines used in module */ typedef struct engine Engine; /* Incomplete definition for Engine */
EXTERN_C int engEvalString(
EXTERN_C Engine *engOpenSingleUse(
const char *startcmd, /* exec command string used to start matlab */ void *reserved, /* reserved for future use, must be NULL */ int *retstatus /* return status */ );
Engine *ep, );
/* engine pointer */
/* string for matlab t execute */
const char *string
VC++绘制天线辐射方向图
EXTERN_C int engSetVisible(
EXTERN_C int engGetVisible(
EXTERN_C Engine *engOpen(
EXTERN_C int engClose(
EXTERN_C mxArray *engGetVariable(
EXTERN_C int engPutVariable(
EXTERN_C int engOutputBuffer(
Engine *ep, /* engine pointer */ bool newVal );
Engine *ep, /* engine pointer */ bool* bVal );
const char *startcmd /* exec command string used to start matlab */ );
Engine *ep /* engine pointer */ );
Engine *ep, );
/* engine pointer */
const char *name /* name of variable to get */
Engine *ep, /* engine pointer */ const char *var_name,
const mxArray *ap /* array pointer */ );
Engine *ep, /* engine pointer */
/* character array to hold output */
/* buffer array length */
char *buffer, int buflen );
VC++绘制天线辐射方向图
#endif /* engine_h */ 5.2主程序
main.cpp #include
#pragma comment( lib, \#pragma comment( lib, \#pragma comment( lib, \#define lambda 1.0 #define L0 1.0 int main() {
Engine *ep;
if(!(ep=engOpen(\{
fprintf(stderr,\return EXIT_FAILURE; } double k; double L; int N=3601; double theta0=0;
const double PI=3.1415926; double *theta=new double[N]; double *fe=new double[N];
k=2*PI/lambda; L=L0*lambda; for(int i=0;i VC++绘制天线辐射方向图 { theta[i]=theta0*PI/180; fe[i]=fabs((cos(k*L*cos(theta[i]))-cos(k*L))/sin(theta[i])); theta0=theta0+0.1; } mxArray *THETA=NULL; mxArray *FE=NULL; THETA=mxCreateDoubleMatrix(1,N,mxREAL); FE=mxCreateDoubleMatrix(1,N,mxREAL); memcpy((void*)mxGetPr(THETA),(void*)theta,N*sizeof(theta[0])); memcpy((void*)mxGetPr(FE),(void*)fe,N*sizeof(fe[0])); engPutVariable(ep,\engPutVariable(ep,\ engEvalString(ep,\printf(\fgetc(stdin); mxDestroyArray(THETA); mxDestroyArray(FE); engEvalString(ep,\engClose(ep); return EXIT_SUCCESS; }