필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Rahim Islam
Rahim Islam 2022년 9월 15일
답변: RAGHUNATHRAJU DASHARATHA 2022년 9월 15일
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
Rahim Islam
Rahim Islam 2022년 9월 15일
I just want to skip this pair. No replacement is deisired.
Rahim Islam
Rahim Islam 2022년 9월 15일
The following will work:
if(x~=0) && (y~=0)
Z=y/x;
else
end

댓글을 달려면 로그인하십시오.

답변 (2개)

KSSV
KSSV 2022년 9월 15일
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 2022년 9월 15일
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;

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by