Domanda

let us consider following article and equation 1

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.30.5925&rep=rep1&type=pdf

what i want is to generate phases uniformly in [-pi pi]interval,let say i need to generate four uniformly distributed phases in this range,i have tried following result

y=zeros(1,4);
for i=1:4
y(i)=-pi+(pi-(-pi)+1)*rand;
end

which gave me following result

2.79219092856020    3.45545787388109    -2.21672413895542   3.51069296177449

but it seems in correct result,so when i have made mistake?please help me

È stato utile?

Soluzione

I don't know what you have added 1 to the interval here:

y(i)=-pi+(pi-(-pi)+1)*rand;
                  ^^^
                why +1 here ???

This should just be:

y(i)=-pi+(pi-(-pi))*rand;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top