Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Writing mathematical equations in MATLAB

  1. Nov 23, 2012 #1
    Hello,

    I have the attached paper, and I want to write equations 4, 5 and the equation in the first line after equation 5 in MATLAB. I did it as following:

    Code (Text):
    Np=24;
    L=19;
    TapsL=[1 19 20];
    S=length(TapsL);

    Index=zeros(S,1);%Tap Locations  
        c=zeros(L+1,1);
        cHatMP=zeros(L+1,1);
        hHatMP=zeros(S,1);%Taps CS Estimates
       
        h=(1/sqrt(2.*(S))).*(randn(S,1)+1i.*randn(S,1));
        c(TapsL)=h;
       
       
        %Channel Estimation
        np=(1/sqrt(2*SNR(ii))).*(randn(Np+L,1)+1i.*randn(Np+L,1));
        n=(1/sqrt(2*SNR(ii))).*(randn(Nd+L,1)+1i.*randn(Nd+L,1));
       
        xpCP=[xp(end-L+1:end);xp];
       
        yp=filter(c,1,xpCP)+np;
       
        yp(1:L)=[]; At this point we have y=Ac+n
       
        cHatLS=inv(transpose(conj(A))*A)*transpose(conj(A))*yp;%Least square channel estimation
       
       
        for ss=1:S
            max=0;
            for pp=1:L+1
                if ss>1
                    set=0;
                    for mm=1:ss-1
                        if Index(mm)==pp
                            set=1;
                        end
                    end
                    if set==0
                        Proj=(abs(transpose(conj(A(:,pp)))*yp)^2)/norm(A(:,pp))^2;
                        if Proj>max
                           max=Proj;
                           maxIndex=pp;
                        end
                    end
                else
                    Proj=(abs(transpose(conj(A(:,pp)))*yp)^2)/norm(A(:,pp))^2;
                    if Proj>max
                       max=Proj;
                       maxIndex=pp;
                    end
                end                  
            end
            hHatMP(ss)=transpose(conj(A(:,maxIndex)))*yp/norm(A(:,maxIndex))^2;
            Index(ss)=maxIndex;
            yp=yp-((transpose(conj(A(:,maxIndex)))*yp*A(:,maxIndex))/norm(A(:,maxIndex))^2);
        end
       
         
        cHatMP(Index)=hHatMP;
    but I get unexpected results when using these values. So, I do not know if I am doing it wrongly in MATLAB. Any suggestion, please?

    Note: Assume A is given.

    Thanks
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Writing mathematical equations in MATLAB
Loading...