Help using For and IF loop

I have generated a random data...I want to convert it to polar form
Pls help me to write codes using for and If

답변 (1개)

UJJWAL
UJJWAL 2012년 3월 1일

0 개 추천

I thought it can be done without using a loop. Maybe I could not understand your question properly because you did not elaborate it well enough.
Here is a code explaining what I did
x = random('gaussian',0,1,[1,50]); %Generating one set of random numbers
y = random('gaussian',0,1,[1,50]); % Generating other set of random numbers
[t,r] = cart2pol(x,y); % Convert from cartesian to polar form
% t will contain the theta part , and r will contain the rho part
If you dont think it is what you want to do , then reply back with a clearer version of the problem
Regards
Ujjwal

댓글 수: 4

Janet
Janet 2012년 3월 1일
I get error
Unrecognized distribution name: 'gaussian
Janet
Janet 2012년 3월 1일
I did this way...but still get error
%Generate random data
len=128;
msg1=randint(len,1);
msg2=randint(len,1);
%Polar_data
for i=1:128
for j=1:128
if msg1(i,j)==0
polar_data1=-1;
else
polar_data1=1;
end
end
end
for i=1:128
for j=1:128
if msg2(i,j)==0
polar_data2=-1;
else
polar_data2=1;
end
end
end
NOTE:
I have to create Mx1 random data and then convert it to polar form
Jan
Jan 2012년 3월 1일
What exactly is the "polar form" in your case? Could you give a short example?
Janet
Janet 2012년 3월 1일
If i have a data 0,then in polar form,it must be converted to -1...
similarly,if it is 1,should be changed to 1

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

카테고리

도움말 센터File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2012년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by