QQ:2335298917
由于STK10以后,STK10与matlab互联需要安装connector,网站上只有32bit版本,因此将32bit connector下载下来并安装。
网站介绍如下:
MATLAB
Connectors Setup andInstallation

MATLAB Interface setup
Starting with STK 10, connectors are required to run AGI M-files and MEX files. STK MATLAB connectors simplify the setup of the MATLAB Interface by automatically configuring the MATLAB file path for a specific MATLAB version. For each supported version of MATLAB, AGI produces a connector, which can be downloaded from the link below:
32-bit connector
Installation instructions for the MATLAB Connectors.
Supported MATLAB versions
The following versions of MATLAB are supported in STK 10: 2008a, 2010a, 2010b, 2011a, 2011b, 2012a, 2012b, 2013a.
由于支持的matlab版本原因,我选择了matlab2011b32bit进行连接。安装顺序,先安装matlab2011b,再安装STK10,最后安装connector。
STK10与matlab互连的设置步骤
1)将“STK安装目录\bin\Matlab”文件夹中的“agiCleanPath.m”、“agiInit.m”、“stkInit.m”复制到“Matlab安装目录\toolbox\local”文件夹中;
2)启动matlab和stk,将matlab当前目录设为“STK安装目录\bin\Matlab”,在matlab中运行指令“stkInit”。
3)显示如下:
>>stkInit
STK MATLAB Interface:  Loaded API at d:\Program Files (x86)\MATLAB\R2011b\bin\win32.
Warning: mexConnect:  Connecting to localhost:5001
这样,matlab与STK10就连接好了,可以在matlab中进行各种命令的发送和设置,stk10会有相应的动作。
以《STK在计算机仿真中的应用》第21章的例子为例,运行结果如下:
将例子代码和文件放到D盘根目录下,并把D盘根目录加入matlab的path中,在matlab中运行STKTest,结果如下:
>>STKTest
Create a new scenario
Set scenario time period
Create a leidazhan1
Create a hangfangleida1 radar
Create a leidazhan2
Create a haifangleida2 radar
Create a new missle
ans =
double
Compute the local horizontal-referenced elevation angle ...
Compute a long range air intercept
Create an external state file and tell STK to load it.
图形如下:
STK10场景如下:
QQ:2335298917
附录:
MATLAB Interface to STK Setup Guide
This guide provides instructions for setting up the interface between MATLAB and STK 10.
Prerequisites
A supported version of MATLAB installed (Check www.agi/matlab for a list of MATLAB versions supported by STK 10.)
STK 10 installed
STK Integration license
A valid STK-MATLAB configuration. For diagrams of valid 32-bit and 64-bit configurations of MATLAB and STK, click here.
Installing an STK MATLAB Connector
The STK MATLAB Connector is the interface that enables communication between MATLAB and STK.
To install the connector:
1.Browse to the MATLAB_Connectors or MATLAB_Connectors_X64 folder on the STK DVD, click and follow the install instructions. (You can also download the latest MATLAB from www.agi/matlab.)
2.To confirm that the installed version of MATLAB is connectable, start STK, go to the Edit menu and select Preferences->MATLAB.
The MATLAB file path is automatically configured to find AGI M-files and MEX files. If you need to reset the MATLAB file path, click Refresh MATLAB Path. (You can also reset the MATLAB file path by selecting Refresh MATLAB Path (32-bit) from the Start->All Programs-> STK Support Tools menu.)
Installing a Connector for a New MATLAB Version
matlab 下载
1.Before installing a connector for a new MATLAB version, check www.agi/matlab to confirm that the new version of MATLAB is supported and a connector exists for that version.
2.Run the latest MATLAB Connector install to ensure that the updated connector is available.
3.Install the new version of MATLAB.
4.To confirm that the installed version of MATLAB is connectable, start STK, go to the Edit menu, and select Preferences->MATLAB.
5.Using the STK Preferences MATLAB page, you can only connect to the most recent version of MATLAB installed. See Connecting to a Different Version of MATLAB to change the version you are connected to.
6.If needed, click Refresh MATLAB Path to reset the MATLAB file path.
Connecting to a Different Version of MATLAB
If you have more than one version of MATLAB installed and you would like to connect to the version installed prior to the last one installed, perform the following steps in MATLAB:
1.Run “matlab /regserver” from the command prompt, with administrator privileges, from the bin folder of the version of MATLAB you want to use. You may need to use the –c option to specify a different MATLAB license file if the administrator is not licensed to run MATLAB.
2.Make sure you have the connectors installed for the version of MATLAB you want to run.