function [wp,wr]=AltMinFS(w,NumRF,NumBits)


% 天线数目
N=numel(w);

Num_Directions=2^NumBits;
Theta_Quantized=pi*(-1+(2*(1:Num_Directions)-1)/Num_Directions); %可用的量化相位

Frf=zeros(N,NumRF);
for m=1:N
    for n=1:NumRF
        Index=randi([1,Num_Directions],1);
        Frf(m,n)=exp(1j*Theta_Quantized(Index));
    end
end

for q=1:20
  fBB=inv(Frf'*Frf)*Frf'*w;  
  Frf=FRFsolving(w,fBB,Frf,Theta_Quantized);
   if norm(w-Frf*fBB)<1e-5
      break;
   end
end
fBB=fBB/norm(Frf*fBB);
wp=Frf*fBB;
wr=norm(w-wp);





