Path: news.mathworks.com!not-for-mail
From: "David Doria" <daviddoria@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Array of class objects?
Date: Tue, 13 Oct 2009 18:50:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <hb2i5a$hp4$1@fred.mathworks.com>
Reply-To: "David Doria" <daviddoria@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255459818 18212 172.30.248.38 (13 Oct 2009 18:50:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 Oct 2009 18:50:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1105197
Xref: news.mathworks.com comp.soft-sys.matlab:577050


If I have a class:

classdef DataPoint
    
    properties
        Point
        ClassId
    end
    
    methods
        function DP = DataPoint(Point, ClassId)
            DP.Point = Point;
            DP.ClassId = ClassId;
        end
        function display(DP)
            disp(['DataPoint: x=', num2str(DP.Point(1)), ' y=', num2str(DP.Point(2))])
        end

    end
    
end

And I want a bunch of DataPoint's in an array, I thought I would make a cell array and store them there:

mypoint = DataPoint([0 2], 1)
test = cell(5,1);
test(1) = mypoint


However I get this error:
??? The following error occurred converting from DataPoint to cell:
Error using ==> cell
Conversion to cell from DataPoint is not possible.
 
How should I make an array of DataPoint's?

Thanks,

Dave