External class method invocation error
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Error message: Error using UGV/rotateby Method 'rotateby' is not defined for class 'UGV' or is removed from MATLAB's search path
I am getting this error when calling a method defined in a sibling function m-file within the class folder holding the class definition file. Here is the directory structure, which looks correct according the the help documentation.

Strange that this code was executing without error 1 day ago. I tried clearing and recreating the object instance. I rehashed the path. I examined the path and the parent folder of the class folder @UGV is on Matlab's search path as per definitions in help for external methods.
Here is the a snippet of the class definition in @UGV/UGV.m:
classdef UGV
properties
dunit = 'foot';
wheeltrack = 2.5; % default track 2.5 ft
wheelbase = 1.25; % default wheelbase 1.25 ft
rho; % rotation radius
...
end
methods
function obj = UGV()
tau = obj.wheeltrack / 2;
beta = obj.wheelbase / 2;
obj.rho = sqrt(tau^2 + beta^2); % rotation radius
end
...
% Rotation trajectory methods
traj = rotateby(obj, ang); % core radian version <<<<< This is the method that is failing
function traj = rotatebyd(obj, deg) % degree version <<<< an internal method that executes
traj = rotateby(obj, deg/180*pi); % but fails on call to external method
end
...
end
...
end
Here is the signature in the @UGV/rotateby.m file
function traj = rotateby(obj, ang)
% rotate UGV instance by angle ang
...
end
Again everything was working until just recently, so I am not sure what is broken. The path and directory structure looks correct. The method signature in the classdef matches that of the external method file. The problem is not an execution error, but the fact that Matlab can't seem to find the method file or doesn't associate it with the class. But help says that Matlab interprets all function m-files in the same class folder as methods of the sibling classdef.
3 Commenti
Catalytic
il 10 Apr 2019
but Mathworks may want to log the issue in case other users encounter this.
It's doubtful that they will. Matt J has already pointed out an error in your set-up. Any MathWorks staff who read this have no reason to think the issue goes any deeper than that.
Risposta accettata
Matt J
il 9 Apr 2019
@UGV is on Matlab's search path
It should not be. The parent folder of @UGV should be on the search path, but not @UGV itself.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Entering Commands in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!