xd = (-1)*(r)*(thd)*sin(theta)-(numer/(2*sqrt(denom)));
where
denom = ((c^2)-(r^2)*(theta));
but denom can be negative, and sqrt() of a negative value will be complex valued.
Looking at
numer = ((r^2) * thd * sin(2*theta));
I would tend to suggest that you should not be multiplying by theta itself, but instead by a trig function of theta.
numer1 = ((cos(2*theta))*4*(r^2)*(thd^2)) * ((c^2) - (r^2)*((sin(theta)).^2));
theta is a 1 x 100 vector, so the left side of the * operation cos(2*theta) is a 1 x 100 vector. The right side of the * operation involves sin(theta) and theta is a 1 x 100 vector, so the right side of the * operation is a 1 x 100 vector.
You therefore have (1 x 100 vector) * (1 x 100 vector) . But * is the algebraic matrix multiplication ("inner product") operator, for which the second dimension of the left operand must be the same as the first dimension of the right operand.
If you are looking for a 100 x 100 result, you will need to transpose() or ctranspose() the left side, so you have (100 x 1) * (1 x 100) giving 100 x 100. If you are looking for a 1 x 1 result, you will need to transpose() or ctranspose() the right side, so you have (1 x 100) * (100 x 1) giving 1 x 1. If you are looking for a 1 x 100 result then * is the wrong operation to use; perhaps you should be using the .* operation.
Best Answer