Structures & Functions

  • Follow


I have a function of the form:

[x, y, z]=myfunc(a, b, c, d)

where a is a function handle, b is a structure and the rest are all vectors.

When I call the function from within a script I get the following error:

"Direct access of structure fields returned by a function call (e.g., call to myscript) is not allowed"

The help refers me to dealing with structures returned from a function call, but I don't have any structures returned, only vectors. The only structure here is an input to the function. I have tried the suggested help of assigning the the structure to another variable (both in the main script and within the function), but it doesn't seem to work, and I'm not sure that this situation applies here.

Anyone have an ideas?

Cheers
Greig
0
Reply Greig 8/25/2010 4:29:05 AM

On 24/08/10 11:29 PM, Greig wrote:
> I have a function of the form:
>
> [x, y, z]=myfunc(a, b, c, d)
>
> where a is a function handle, b is a structure and the rest are all
> vectors.
>
> When I call the function from within a script I get the following error:
>
> "Direct access of structure fields returned by a function call (e.g.,
> call to myscript) is not allowed"

Does your script contain any attempts to invoke functions or scripts by 
naming the complete .m file? Such as (e.g)

InitializeThings.m     %Set up my variables

If so then you need to get rid of the .m
0
Reply Walter 8/25/2010 4:59:27 AM


Walter Roberson <roberson@hushmail.com> wrote in message <Pq1do.64866$Zp1.18588@newsfe15.iad>...
> On 24/08/10 11:29 PM, Greig wrote:
> > I have a function of the form:
> >
> > [x, y, z]=myfunc(a, b, c, d)
> >
> > where a is a function handle, b is a structure and the rest are all
> > vectors.
> >
> > When I call the function from within a script I get the following error:
> >
> > "Direct access of structure fields returned by a function call (e.g.,
> > call to myscript) is not allowed"
> 
> Does your script contain any attempts to invoke functions or scripts by 
> naming the complete .m file? Such as (e.g)
> 
> InitializeThings.m     %Set up my variables
> 
> If so then you need to get rid of the .m

Aha! So simple, all sorted now.

Cheers
Greig
0
Reply Greig 8/25/2010 5:13:04 AM

2 Replies
438 Views

(page loaded in 0.018 seconds)

Similiar Articles:













7/21/2012 8:47:18 PM


Reply: