Feeding DATA from MATLAB to JavaScript function
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a simple JavaScript, which I would love to control using MATLAB. Here is the code for the JavaScript function. Pardon my JavaScript code, I am new to this JavaScript :)
// fliegen.js
/*
Copyright 2011
Licence thingy
*/
// Converts a given distance to latitude and longitude.
//
// To be used with Google Earth Plugin
function fliegen(lat1,lon1,alt,theta,d,tilt) {
// Define the variables
var theta, R = 6371, d, lat1, lon1, lat2, lon2, tilt,alt
// Convert the given start latitude,longitude and heading to radian
theta = theta*Math.PI/180;
lat1 = lat1*Math.PI/180;
lon1 = lon1*Math.PI/180;
// Calculate the next position
lat2 = Math.asin(Math.sin(lat1)*Math.cos(d/R) + Math.cos(lat1)*Math.sin(d/R)*Math.cos(theta));
lon2 = lon1 + Math.atan2(Math.sin(theta)*Math.sin(d/R)*Math.cos(lat1), Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
// Convert back to degree
lat2 = lat2*180/Math.PI;
lon2 = lon2*180/Math.PI;
theta = theta*180/Math.PI;
// Get the current view
var camera = ge.getView().copyAsCamera(ge.ALTITUDE_ABSOLUTE);
// Set new latitude and longitude values
camera.setLatitude(lat2);
camera.setLongitude(lon2);
camera.setAltitude(alt);
camera.setHeading(theta);
camera.setTilt(tilt);
// Update view in Google Earth
ge.getView().setAbstractView(camera);
}
I want to feed the variables needed for the function from a MATLAB simulation. My idea is to interface MATLAB and the Internet Browser (IE or Firefox etc) using COM interface. Is it possible to do so?
Is there any better solution than using COM?
Thanks.
댓글 수: 0
답변 (1개)
Kaustubha Govind
2011년 5월 3일
Yes, it is possible to start MATLAB as a COM server from your web application. Here is an example that uses VBScript: http://www.mathworks.com/help/techdoc/matlab_external/f135590.html#bqg5h5b
댓글 수: 2
Kaustubha Govind
2011년 5월 17일
MATLAB also has COM client support. See: http://www.mathworks.com/help/techdoc/matlab_external/brd0v8r.html
참고 항목
카테고리
Help Center 및 File Exchange에서 Google Earth에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!