It's from this question。
Why the two solutions doesn't work, though it looks very valid for me:
>> t = -pi:0.1:pi;
>> r = ((sin(t)*sqrt(cos(t)))*(sin(t) + (7/5))^(-1)) - 2*sin(t) + 2 ;
??? Error using ==> mtimes
Inner matrix dimensions must agree.
>> t = -pi:0.1:pi;
>> r = ((sin(t).*sqrt(cos(t))开发者_如何学运维).*(sin(t) + (7/5)).^(-1)) - 2*sin(t) + 2 ;
>> plot(r,t)
??? Error using ==> plot
Vectors must be the same lengths.
What's wrong with the above?
The *
operator is the matrix multiplication operator, which requires its operands to have matching inner matrix dimensions. The .*
operator is the element-wise multiplication operator, which requires its operands to have the same size (or for one to be a scalar) so it can perform multiplication on each matching pair of elements. See this link for more detail.
Also, I don't get the plotting error you do when I run the second solution. I just get this warning:
Warning: Imaginary parts of complex X and/or Y arguments ignored
精彩评论