I need your help in MATLAB for constructing a shape.
First I need to draw a triangular mesh ( delaunay). I would like to generate an inscribed triangle in each triangle of this mesh in such a way that the distance between the inscribed and mesh triangle lies between 0-1 ( using normal or lognormal distribution)...
So far I used the following program :
x = randn(1,12); y = randn(1,12); tri = delaunay(x,y);
t=randn(1,1)
for k=1:12 p1=[x(tri(k,1)),y(tri(k,1))]
p2=[x(tri(k,2)),y(tri(k,2))]
p3=[x(tri(k,3)),y(tri(k,3))]
P0 = (P1 +P2+P3(k))/3;
Q1 = t*P1(k)+(1-t)*P0;
Q2(k) = t*P2(k)+(1-t)*P0;
Q3(k) = t*P3(k)+(1-t)*P0;
end
It returns error to me as :
In an assignment A(I) = B, the number of elements in B and I must be the same.
I think it might be due to the fact that I am trying to save in P1, the array of 2 variables. However what I think is that I have to store the co-ordinates of each vertice of the triangle in some form.
Please guide me to solve this problem