Undefined function 'abc' for input arguments of type 'double'.
Show older comments
I'm trying to create a flowfield class, but am getting errors when I'm creating functions
just calling
abc(n);
gets me an error
function abc(obj,n)
obj.state=n;
end
Full code
classdef flowfield < handle
% Public properties
properties (Access = public)
size int64 = [10,10];
origin int64 = [3,4];
distance double;
direction double;
open_set
current_pos;
state;
end
methods (Access = public)
% Constructor
function obj = flowfield()
open_set = queue(2);
open_set.enqueue(obj.origin);
obj.distance = inf(obj.size);
obj.direction = NaN(obj.size);
% Main loop
while (~open_set.isempty)
obj.current_pos = open_set.dequeue;
%pos=obj.current_pos+[1,-1];
obj.state=1;
n=1;
abc(n);
% update_node(obj.current_pos+[1,0]);
% update_node(obj.current_pos+[1,1]);
% update_node(obj.current_pos+[0,1]);
% update_node(obj.current_pos+[-1,1]);
% update_node(obj.current_pos+[-1,0]);
% update_node(obj.current_pos+[-1,-1]);
% update_node(obj.current_pos+[0,-1]);
end
end
function abc(obj,n)
obj.state=n;
end
end
methods (Access = public)
function update_nodea(obj, pos)
% If out of bounds
if ( 0>=pos(1) || pos(1)>obj.size(1) ) || ...
( 0>=pos(2) || pos(2)>obj.size(2) )
return
end
new_value = obj.map(obj.current_pos) + norm(obj.current_pos, pos); % adds current distence with distence between both nodes
if (obj.map(pos) > new_value)
obj.map(pos) = new_value;
obj.open_set.enqueue(pos);
end
end
end
end
Answers (1)
Steven Lord
on 1 Mar 2022
0 votes
The way you've defined your method, one or both of the inputs obj and n to your method must be an instance of the class. You're only providing one input to the function and that input is not an instance of the flowfield class, so MATLAB will not even try to call the class method.
Categories
Find more on Whos 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!