your class is missing a constructor. furthermore you never initialize any object.
your floating_search.S = x;
statement generates a struct called floating_search
:
>> whos floating_search
Name Size Bytes Class Attributes
floating_search 1x1 256 struct
Try this instead (save file as floating_search.m
):
classdef floating_search
properties
S;
M;
end
methods
% constructor - place to initialize things
function obj = floating_search()
end
% you need the first input argument 'obj', since this is a value class
% see http://www.mathworks.de/de/help/matlab/matlab_oop/comparing-handle-and-value-classes.html
function s = support(obj, x, y)
for i=1:length(x)
if(y(i)~=1)
s = x(i);
end
end
end
end
end
and then run the code:
% generate your data
x = 1:10;
y = trapmf(x,[1 3 5 9]);
# initialize object
a = floating_search()
a.S = x;
a.M = y;
a.support(a.S, a.M)