z=sqrt(x^2+y^2) c=(z<15) imshow(c) gives a square cut diagonally half with lower right side being white and other being black z=sqrt(x.^2+y.^2) c=(z<15) imshow(c) gives a square with circle in centre What is the difference between (x^2+y^2) and (x.^2+y.^2) in matlab?

0 |

1/29/2016 1:33:04 AM

"Sagar Chand" <sagarchand_9@rediffmail.com> wrote in message <n8efgg$100$1@newscl01ah.mathworks.com>... > z=sqrt(x^2+y^2) > c=(z<15) > imshow(c) > gives a square cut diagonally half with lower right side being white and other being black > > z=sqrt(x.^2+y.^2) > c=(z<15) > imshow(c) > gives a square with circle in centre > > What is the difference between (x^2+y^2) and (x.^2+y.^2) in matlab? The ^ operator (without the period) is matrix power. The .^ operator (with the period) is element-by-element power. Hence you will get different results if x or y are not scalar. James Tursa

0 |

1/29/2016 2:12:03 AM