This question is closed. Reopen it to edit or answer.
Problem with for loop
1 view (last 30 days)
I want to obtain the middle points of each panel of a closed circle, for that I'm using the for loop. For example, the length of xc is 9 thus i = 8, but I get a matrix of dimension 1x9 for xc and yc, where the first element is equal to 0. Why is this happening and how can I obtain xc and yc of dimensions 1x8?
Thanks in advance.
for i = 2:1:length(xp);
xc(i) = (xp(i-1)+xp(i))/2;
yc(i) = (yp(i-1)+yp(i))/2;
madhan ravi on 15 Nov 2018
your loop produces eight elements but you already defined the first element for each variable as 0 , if you want to know what i mean type
xc(2) %which is the first element of loop but second element of the vector itself
xc(1) %which will be zero because it's predefined