MATLAB: Error: Index Exceeds Matrix Dimensions. Please Help

errorindex exceeds matrix dimensionsoop

Hi,
I have simplified my problem, in the code below. Basically, every time I run this code, and request function "pos" with the following command:
a=class
a.pos
I receive the following error:
Index exceeds matrix dimensions.
Error in c/pos (line 15)
p=obj.x(m)
Hopefully someone can tell me what I am doing wrong. Thank you.
classdef class<handle
properties
m=[];
x=[];
end
methods
function obj=c()
end
function [x,m]=pos(obj)
x=[2 3]
m=[1]
p=obj.x(m)
end
end
end

Best Answer

You assigned [2 3] to the local variable x, not to obj.x . obj.x is still its initial value []