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

coms-functionsimulink

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);

Best Answer

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!
Related Question