I found some related questions, but didn't really find an answer in there.
I'm writing a simple little MATLAB class in order to learn OOP syntax in MATLAB. I'm very familiar with Python, and pulling my hair out trying to work with MATLAB. Here's the definition:
classdef Car < handle
properties
speed = [0,0] %x,y velocity
position = [0,0]
running = false
end
methods
function obj = Car(pos, spd)
obj.position = pos;
obj.speed = spd;
end
function accelerate(obj,x,y) % Add to speed
obj.speed = obj.speed + [x,y]
end
function position = getPosition(obj)
position = obj.position
end
function start(obj)
obj.running = true
end
function stop(obj)
obj.running = false
end
end
end
This is certainly not done, but then I'm using a little script to mess with the object:
foo = Car([1,1],[0,2])
foo.start
foo.accelerate(2,3)
Instantiation works, but ANY method I call throws an error. foo.start, for example:
Error using Car/start
Too many input arguments.
What am I missing??