Home > Mobile >  MATLAB | Invalid syntax for calling function 'cond' on the path. Use a valid syntax or exp
MATLAB | Invalid syntax for calling function 'cond' on the path. Use a valid syntax or exp

Time:11-25

I want to extract data from a table called cond. As you can see from line 75 in the screenshot shown below, data Diameter corresponding to Drake can be successfully extracted using cond('Drake',:).Diameter.

screenshot

However, when I was trying to write this into a function called findCF(), things went wrong at line 78 with an error message

Invalid syntax for calling function 'cond' on the path. Use a valid syntax or explicitly initialize 'cond' to make it a variable.

Can anybody tell me how to modify my code?

CodePudding user response:

cond() is the name of a built-in function. Matlab tolerates variables whose names collide with functions, but it can result in weird things like this. In the line that produces the error, Matlab thinks you are trying to call the function cond(), not access the variable cond.

Rename the variable to something else.

  • Related