Updating object properties after instantiation

3 views (last 30 days)
I'm writing a program in which I create a number of objects - Rectangle objects that consist of four objects of class GridPoint (an ordered pair of integers - coordinate points, really), which define the corners of each Rectangle object. Properties of the GridPoint object are:
x, y, type, nXpos = Neighbor; nYpos = Neighbor; nXneg = Neighbor; nYneg = Neighbor;
So, (x,y) are point coordinates, type refers to the category of each point (not important here), and nXpos is the neighbor GridPoint in the positive x direction, and the other names are similarly explained.
My constructor for class GridPoint uses signature: GridPoint(int, int, int). The first value in the parameter list is the x coordinate, the second the y, and the third the type. As for the other properties of the GridPoint objects (Neighbor points), they are attached to each object later.
The problem is, the code keeps breaking with "Not enough input arguments" error. The weird part is that it breaks a few times, I simply delete and then paste back in some code in one of my functions, and it works again until I make substantial enough changes, then it breaks again until I do the same absurd actions to fix it.
Can anyone explain this to me? Thanks!

Answers (1)

per isakson
per isakson on 3 Mar 2014
Edited: per isakson on 3 Mar 2014
What you describe sounds weird. Without more detail it is hard to say what is going on. Does your class look something like this?
>> gp = GridPoint(1,2,3);
>> gp.x=12
gp =
GridPoint with properties:
x: 12
y: 2
type: 3
nXpos: []
nYpos: []
nXneg: []
nYneg: []
where
classdef GridPoint
properties
x
y
type
nXpos % = Neighbor;
nYpos % = Neighbor;
nXneg % = Neighbor;
nYneg % = Neighbor;
end
methods
function this = GridPoint( x, y, type )
this.x = x;
this.y = y;
this.type = type;
end
end
end
  4 Comments
jjjjj
jjjjj on 3 Mar 2014
Yes, each GridPoint object creates four Neighbor objects (each a GridPoint), up to two which could be null. But even if I exclude the function that creates the "neighborhood" of GridPoint objects, the error persists.
This is by design - every point in my grid has up to four other GridPoint objects as neighbors.
per isakson
per isakson on 3 Mar 2014
  • Yes, but your mesh of grid_point must be finite, fit in memory.
  • My understanding of the behavior is too vague to do anything but guessing.
  • Could you upload an example, which shows the behavior?

Sign in to comment.

Categories

Find more on Agriculture in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!