Hi Vapeur,
It is difficult to tackle the issue without seeing the actual error. However, seeing your code, there is an obvious error in your methods, which is that you must pass in the object as the first argument of each method. This is expected for MATLAB. For example, you have:
function this = Particle()
this.position=[0 0];
this.velocity=[1.*rand(100,1) 1.*rand(100,1)];
end
The syntax is incorrect. Instead you need to have:
function Particle(obj)
obj.position=[0 0];
obj.velocity=[1.*rand(100,1) 1.*rand(100,1)];
end
Note the first argument in the "Particle" method is the object itself. Also this is a void function so no output is specified.
Another example is with regards to your "move" method.
function [position] = move (velocity)
position=Particle.this.position+velocity;
end
I am guessing that you are outputting the updated position by the velocity input. Remember that the first argument MATLAB expects is the object itself. So you need to have something like this:
function [position] = move (obj, velocity)
position = obj.position+velocity;
end
Try to fix other parts of your code in the methods section. For example, in your "react" method, you need to start with:
function velocity = react(obj)
...
end
Best of luck on your endeavors!
Thanks,
David