Feeding DATA from MATLAB to JavaScript function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Kaustubha Govind
le 3 Mai 2011
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 commentaires
Kaustubha Govind
le 17 Mai 2011
MATLAB also has COM client support. See: http://www.mathworks.com/help/techdoc/matlab_external/brd0v8r.html
Voir également
Catégories
En savoir plus sur Use COM Objects in MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!