Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Attempt to execute SCRIPT <variable> as a function

Subject: Attempt to execute SCRIPT <variable> as a function

From: DB DB

Date: 1 Sep, 2012 01:42:14

Message: 1 of 3

I created a function and within the function I am calling in a .mat file and running some calcultions (e.g, file.mat and variable2=variable0.*variable1). However, when I execute the function, it yields the following error:

??? Attempt to execute SCRIPT cs as a function:
/Applications/MATLAB_R2011a.app/toolbox/ident/iddemos/cs.m

where cs is my variable name. I tried changing this variable within the function but I guess this doesn't work. What can I do without having to change the .mat file?

Thanks so much

Subject: Attempt to execute SCRIPT <variable> as a function

From: MALATHI

Date: 1 Sep, 2012 05:26:06

Message: 2 of 3

"DB DB" <denrick888@gmail.com> wrote in message <k1rp5l$m1i$1@newscl01ah.mathworks.com>...
> I created a function and within the function I am calling in a .mat file and running some calcultions (e.g, file.mat and variable2=variable0.*variable1). However, when I execute the function, it yields the following error:
>
> ??? Attempt to execute SCRIPT cs as a function:
> /Applications/MATLAB_R2011a.app/toolbox/ident/iddemos/cs.m
>
> where cs is my variable name. I tried changing this variable within the function but I guess this doesn't work. What can I do without having to change the .mat file?
>
> Thanks so much

Hi,
I have experienced the same problem.
For me, I didn't include the function declaration in my Matlab function file.

I think in the function file cs, u have missed the first line,
function cs = [ your input]

Regards,
Malathi.

Subject: Attempt to execute SCRIPT <variable> as a function

From: Steven_Lord

Date: 4 Sep, 2012 15:08:20

Message: 3 of 3



"DB DB" <denrick888@gmail.com> wrote in message
news:k1rp5l$m1i$1@newscl01ah.mathworks.com...
> I created a function and within the function I am calling in a .mat file
> and running some calcultions (e.g, file.mat and
> variable2=variable0.*variable1). However, when I execute the function, it
> yields the following error:
>
> ??? Attempt to execute SCRIPT cs as a function:
> /Applications/MATLAB_R2011a.app/toolbox/ident/iddemos/cs.m
>
> where cs is my variable name. I tried changing this variable within the
> function but I guess this doesn't work. What can I do without having to
> change the .mat file?

Don't "poof" the data into your function's workspace.

http://www.mathworks.com/matlabcentral/newsreader/view_thread/316326#865337

Call LOAD with an output argument and either use the struct array field
directly (perhaps using dynamic field names) or explicitly create a variable
using that struct array field then use that variable later in your code.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

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.

Contact us