Reputation: 799
I have the following code;
x = -12:1/32:12;
y = -12:1/32:12;
[X,Y] = meshgrid(x,y);
z = (sin(sqrt(X.^2+Y.^2)))/(sqrt(X.^2+Y.^2))
For some reason it always returns NaN and I don't get it if I make
z = (sin(sqrt(X.^2+Y.^2)))
I actually get numbers. What is the problem?
Upvotes: 0
Views: 42
Reputation: 1264
Perhaps you are after:
z = (sin(sqrt(X.^2+Y.^2)))./(sqrt(X.^2+Y.^2));
which element-wise division rather than matrix division.
Upvotes: 2