Sorry

Does linspace create an integer array of 1..lengthinputpositions of length lengthinputpositions?
I think that's all I use it for here, but linspace is more general; linspace(a,b,n) creates a 1-by-n vector which contains values (not necessarily integers) linearly spaced between and including a and b. I think in the code I posted, I mostly do linspace(1,n,n), which just counts integers from 1 to n.
>> linspace(1,10,10)
ans =
1 2 3 4 5 6 7 8 9 10
>> linspace(1,pi,4)
ans =
1.0000 1.7139 2.4277 3.1416
In the instance you quote, I'm just numbering the trees, which to begin with are the input points themselves.
what does transposing it do? I'm assuming it's changing it from a vector Ai1 to A1i but I don't understand why.
Yep, that's exactly what it does. Here, it's from an earlier version of the code in which it was necessary, but now it isn't so I've removed it. I think I transposed it to get a column vector I could attach as a column to one of the other arrays.
EDIT*: But I transpose elsewhere in the code, because to feed elements of a vector into a for loop,
for i=somevector
...
end
the vector needs to be a row vector. Otherwise, there will only be one i, and it'll be a column vector. So I only transpose to put a vector in the right shape for iterating. Partly because of this, I like the way C does loops, but anyway - I don't think you'll have to tranpose at all.
remainingpositionxs=inputpositionxs(find(maskvector==0));What does this code do? I gues the == is a check for equality
Yes. == < <= > >= all return 1 if the relational condition is satisfied (and zero otherwise).
>> [-2,-1,0,1,2]==1
ans =
0 0 0 1 0
>> [-2,-1,0,1,2]>=1
ans =
0 0 0 1 1
does that 'find' then filter out all the zeros from inputpositions?
Right again - find returns the indices of all nonzero elements of a vector. If the vector was row or column, find(vector) will be row or column respectively.
>> find([-1,0,1])
ans =
1 3
because only the second element is zero.
So find is handy for retrieving indices of elements that satisfy some condition.
Does unique imply that the array it returns is sorted in anyway or does it give the unique elements in the order that they're found?
It gives unique elements in ascending order.
>> unique([1,1,4,3])
ans =
1 3 4
But as with the transpose thing, it's a redundant operation from an earlier version of the code, and I've removed this too.
Also does 'length' return the same result as numel?
For a vector (which is all I use it on here), yes.
Okay, now I'll see if I can spot anything else . . .
In a few places I manipulate arrays
[a,b,c] makes a row vector
[a;b;c] makes a column vector
[] is nothing - like declaring a 0-by-0 array that can have other arrays appended to it
array(:,2) returns the second column from the left of array (not the third like in C)
array(2,:) returns the second row from the top of array
xextent=eps;
eps is just a small number, 2.2204e-16, so that the area or volume (measure) can't be zero, which causes problems.
.* is element-wise multiplication, rather than matrix multiplication.
size(array) returns a vector which measures array (in numbers of rows and columns) - it's {number of rows, number of columns}, if array is only two-dimensional.
Sorry abut those (especially the bits that were redundant leftovers

), hassle me about anything else I haven't made clear, by post or PM.
*EDIT: above, about the transpose.