Thread Subject: Simulink Error!

Subject: Simulink Error!

From: Shewie Ferrari

Date: 12 Mar, 2010 14:33:21

Message: 1 of 4

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"...
(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!
But in simulink he shows me:
A =
   44.2922 12.0239 10.4000

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?!
Tnx and sorry for my english! :D

Subject: Simulink Error!

From: Steven Lord

Date: 12 Mar, 2010 14:50:54

Message: 2 of 4


"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

Subject: Simulink Error!

From: Shewie Ferrari

Date: 12 Mar, 2010 14:56:05

Message: 3 of 4

Tnx a lot!

Subject: Simulink Error!

From: Shewie Ferrari

Date: 12 Mar, 2010 15:03:09

Message: 4 of 4

i replaced GECamera(....)
with the .m name GECamera
but...

Embedded MATLAB Interface Error: Error reported by S-function 'sf_sfun' in 'SLuno/Simulink Embedded MY_camera/ SFunction ':
The function, script, or class ge
cannot be indexed using {} or . indexing.
Block Simulink Embedded MY_camera (#31)
While executing: none

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Shewie Ferrari 12 Mar, 2010 09:34:31
sl Shewie Ferrari 12 Mar, 2010 09:34:31
matlab Shewie Ferrari 12 Mar, 2010 09:34:31
googleearth Shewie Ferrari 12 Mar, 2010 09:34:31
google Shewie Ferrari 12 Mar, 2010 09:34:31
earth Shewie Ferrari 12 Mar, 2010 09:34:31
variable Shewie Ferrari 12 Mar, 2010 09:34:31
variables Shewie Ferrari 12 Mar, 2010 09:34:31
error Shewie Ferrari 12 Mar, 2010 09:34:31
rssFeed for this Thread

Contact us at files@mathworks.com