Avoiding (X,Y)=(0,0) from loop

I want to avoid (0,0) value for (X,Y). How can I achive it?
M=64;
r = linspace(0,1,M);
theta = linspace(0,2*pi,M);
[R, THETA] = meshgrid(r,theta);
X = R.*cos(THETA);
Y = R.*sin(THETA);

3 comentarios

KSSV
KSSV el 15 de Sept. de 2022
You want to avoid in the sense, you want to replace it with some other number or NaN?
Rahim Islam
Rahim Islam el 15 de Sept. de 2022
I just want to skip this pair. No replacement is deisired.
Rahim Islam
Rahim Islam el 15 de Sept. de 2022
The following will work:
if(x~=0) && (y~=0)
Z=y/x;
else
end

Iniciar sesión para comentar.

Respuestas (2)

KSSV
KSSV el 15 de Sept. de 2022

0 votos

M=64;
r = linspace(10^-3,1,M);
theta = linspace(0,2*pi,M);
[R, THETA] = meshgrid(r,theta);
X = R.*cos(THETA);
Y = R.*sin(THETA);
idx = X==0 & Y == 0 ;
RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA el 15 de Sept. de 2022

0 votos

As per my understanding you want to avoid the value (0,0) for (X,Y) in your code
I will be demonstrating it using your code. I have just made a change to your code for the value X and Y
M=64;
r = linspace(0,1, M);
theta = linspace(0,2*pi, M);
[R, THETA] = meshgrid(r,theta);
X = R(:,2: end).*cos(THETA(:,2:end));
Y = R(:,2:end).*sin(THETA(:,2:end));
Z =Y./X;

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 15 de Sept. de 2022

Respondida:

el 15 de Sept. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by