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

조회 수: 1 (최근 30일)
Wan Nawi
Wan Nawi 2011년 4월 7일
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에서 Simulink Functions에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by