The CLASS function must be called from a class constructor.
Show older comments
I'm currently working on a project involving some automatic differentiation, and was presented an example code to such an approach. My problems really boil down to me never working with OOD in Matlab before and it seems really overwhelming. The first part of the code looks like this, fairly straight forward. The problem is it won't run past the last line.
function ad = autodiff(val, der)
% A naive autodiff constructor.
ad.val = val;
if nargin == 1
der = 0.0;
end
if strcmp(der,'variable')
der = 1.0;
end
ad.der = der;
ad = class(ad, 'autodiff');
I get the error 'The CLASS function must be called from a class constructor', which I do not know how to deal with. How do I create custom classes and then call upon them later?
thanks in advance, Kristian
2 Comments
James Tursa
on 6 Feb 2013
Did you have this file in a directory named '@autodiff', and is the directory that the @autodiff folder is in on the MATLAB path?
hossein
on 24 Jun 2017
would you please explain more about the directory and @autodiff folder
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!