COM (Component Object Model) as S-Function Block in Simulink

1 次查看(过去 30 天)
Hello all,
I know that MATLAB can utilize COM and acts as server or client. I am trying to create a direct interface between Simulink and COM.
I have a Simulink Model of a takeoff maneuver and want to display it in Google Earth. I've succeeded doing that by saving the simulation data from Simulink in Workspace, and feeding the saved data to the COM.
My target is actually to have Simulink outputs the data in real time to COM. To interface MATLAB and COM, I use a MATLAB function. Is it possible to integrate the function in Simulink using S-Function block?
Thanks!
Here is the code:
function gEarthCOM(position,view)
%This function will create a COM server running Google Earth and control
%the Google Earth's camera with given properties
% usage: Before using this function, you must create a COM server with this
% command:
% handle = actxserver('googleearth.ApplicationGE');
% position is a vector containing latitude, longitude, and altitude
% view is a vector containing range,tilt, and heading
% altmode and speed will be set in this function
%
% Go to first position
% handle.SetCameraParams(position(1),position(2),position(3),1,...
% view(1),view(2),view(3),5);
% pause (5)
handle = actxserver('googleearth.ApplicationGE');
newPosition = handle.GetCamera(0);
set (newPosition, 'FocusPointLatitude', position(1));
set (newPosition, 'FocusPointLongitude', position(2));
set (newPosition, 'FocusPointAltitude', position(3));
set (newPosition, 'FocusPointAltitudeMode', 2);
set (newPosition, 'Range', view(1));
set (newPosition, 'Tilt', view(2));
set (newPosition, 'Azimuth', view(3));
handle.SetCamera(newPosition,5);

采纳的回答

Jarrod Rivituso
Jarrod Rivituso 2011-4-7
I've never tried exactly what you are describing. However, the "Level-2 MATLAB S-function" block may allow you to do this.
I would first try and call your COM routines in MATLAB. Then, after that, try and wrap them in a "Level-2 MATLAB S-function" in Simulink.
Good luck!

更多回答(1 个)

Wan Nawi
Wan Nawi 2011-4-8
Just realized that S-Function is maybe not needed here. With the simple code above, using Embedded Matlab Function is maybe enough. I just need to declare the function as extrinsic and let Matlab execute it. It is working. But, maybe there is more elegant solution

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by