Feeding DATA from MATLAB to JavaScript function

2 visualizzazioni (ultimi 30 giorni)
Wan Nawi
Wan Nawi il 2 Mag 2011
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.

Risposte (1)

Kaustubha Govind
Kaustubha Govind il 3 Mag 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 Commenti
Wan Nawi
Wan Nawi il 17 Mag 2011
Thanks for the answer. What I really want to do is to have MATLAB/Simulink as COM Client, not a COM server. The JavaScript is only for displaying the result of the simulation.
Kaustubha Govind
Kaustubha Govind il 17 Mag 2011
MATLAB also has COM client support. See: http://www.mathworks.com/help/techdoc/matlab_external/brd0v8r.html

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by