|
"Shewie Ferrari" <albyfer@libero.it> wrote in message
news:hndjbh$42n$1@fred.mathworks.com...
> Hi all... i've got some problems with Simulink variables.
> I try to explain my work:
> in input i've got a data(matrix) in matlab (latitude, long, altitude)
> then, after open Google Earth, with an embedded function, move the
> camera...
>
> I've just completed all my work with Matlab, all works fine... camera
> position, simulation...
>
> My next step then is to use Simulink.
>
> My problem is the seguent:
> i've got a function that take variables from matlab, constants for
> speed/focus point camera... and all works fine.
> Then i've to link all with a pack called My_GE_Camera and use a function
> called GE_Camera and refresh the status of all my variables.
>
> This is My_GE_Camera:
> function MY_camera(LAT,LON,ALT,Heading,FocusPoint,Inclinazione,Speed)
> A=[LAT LON ALT]
> camera=[FocusPoint Inclinazione Heading]
> GEcamera(ge,A,camera,Speed)
>
> It tell me that he dont' find the variable "ge"...
That is correct -- you never define a variable named ge inside your
MY_camera function, nor do you pass it into the function as an input
argument.
> (don't find the inputs - i start the simulation and he tell me that he
> need 2 input and he find 0)
> (on Matlab i used ge=geserver; (a function that start Google Earth)
> function ge_out = GEserver(ge_in)
> persistent ge;
> if nargin>=1,
> ge = ge_in;
> end;
> if (~exist('ge','var') || isempty(ge)),
> ge = actxserver('GoogleEarth.ApplicationGE');
> end;
> ge_out = ge;
>
> Then i tought to execute my function inside GECamera(...) then it take the
> variable in matlab's workspace
>
> function MY_camera(LAT,LON,ALT,Heading,FocusPoint,Inclinazione,Speed)
> A=[LAT LON ALT]
> camera=[FocusPoint Inclinazione Heading]
> My_GE_camera;
>
> But this time it tell me that in My_GE_camera, the variable "A" is not
> defined!
That's correct -- you don't pass A from the MY_camera function into the
My_GE_camera.
> But in simulink he shows me:
> A =
> 44.2922 12.0239 10.4000
Yes, this variable is defined ... inside the workspace of the ***MY_camera
function***, NOT inside the workspace of the ***My_GE_camera function***.
> camera =
> 120 80 339
>
> ??? Undefined function or variable "A".
>
> Error in ==> My_GE_camera at 1
> GEcamera(ge,A,camera,Speed)
>
> Can you help me please?!
I strongly suggest you review the sections "Scripts" and "Functions" in the
MATLAB documentation on working with scripts and functions:
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f7-38085.html
This will hopefully give you a better understanding of the differences
between the two and how functions can generally only work on information
that's in their workspaces (and for the gurus out there, I know the details
I'm glossing over and I'm intentionally glossing over them.)
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|