Date: Nov 12, 2013 3:49 PM
Author: Steven Lord
Subject: Re: Undefined function or variable - for no reason...

"Rafa " <rafael.ballesterripoll@uzh.ch> wrote in message

news:l5tln8$s74$1@newscl01ah.mathworks.com...

> Hi all,

> I'm having the same problem here. In my case, functions don't run when

> they are part of a class folder (i.e. starting with '@'). So I have the

> strange behaviour:

>

>>> which -all ttm

> /home/rafa/tensor_toolbox/@ttensor/ttm.m % ttensor method

> /home/rafa/tensor_toolbox/@tensor/ttm.m % tensor method

> /home/rafa/tensor_toolbox/@sptensor/ttm.m % sptensor method

> /home/rafa/tensor_toolbox/@ktensor/ttm.m % ktensor method

>>> ttm

> Undefined function or variable 'ttm'.

>

> ('ttm' is a perfectly valid file from a widely-used toolbox, it used to

> work until it randomly broke, and the '/home/rafa/tensor_toolbox/' folder

> belongs to the path, as it should be)

>

> In general, a lot of confusion seems to exist around these 'undefined'

> error issues. Anyone has any clue?

Note that all four of those function paths have a comment "<something>

method" at the end? That means they are class methods and you MUST call them

with an instance of that class for at least one of the inputs (unless

they're Static methods, in which case you need to call them using the name

of the class.)

http://www.mathworks.com/help/matlab/matlab_oop/specifying-methods-and-functions.html

If those methods are NOT Static, you would need to call them with at least

one ttensor object as input (in which case the first method is called), a

tensor object as input (second method), a sptensor object (third), or a

ktensor (fourth.) Your call with 0 inputs doesn't give ANY of those objects

as input, so MATLAB doesn't know which method to call and so doesn't call

any of them. Since there's no non-method function named ttm visible to

MATLAB (it would have shown up in the WHICH output if there were) it

correctly says essentially "I don't know what you want me to do."

If they were Static and accepted 0 inputs, you would call them as:

ttensor.ttm()

tensor.ttm()

sptensor.ttm()

ktensor.ttm()

The help for those methods should indicate the correct way to call them.

help ttensor.ttm

--

Steve Lord

slord@mathworks.com

To contact Technical Support use the Contact Us link on

http://www.mathworks.com