ارجووووووووو المساعدة هاااااااام

السلام عليكم
اخواني ارجو المساعدة

اريد ان اكتب هذه المعادلات على الماتلاب بحيث انو لما ادخل اي قيمة يعطيني جواب
يعني اعرف قيم متغيرات و يعطيني قيم لهذه المعادلات
h: entropy
n-1
H(l) = Σ Pk log(1/Pk)
k=0 2
n= 1,2,3,4…1000


R: redunduncy
H(l)max = log n
2

R= H(l) - Hmax

Rs : bauf Rate (=1024)
Ri : information rate

Ri = Rs*H(l)
ارجو المساعدة العاجلة

%[h , R , Ri] = entropy(M)


function [h , R , Ri] = entropy(M)

Rs = 1024 ; % symbols/s , baud rate
PI = [0.5 0.2 0.2 0.1]'; % the probabilities of 
%symbols [p(A) p(B) p(C) p(D)]

    h = 0;  
    
    for i = 1:M  
         
                if (PI(i) == 0) h= h ;
                else    
                h = h - PI(i)*log2(PI(i));   
                end;
    end 
    

R = log2(M) - h ;  % redundancy
Ri = Rs * h  ;  % information rate of the source            
end     

لتنفيذ البرنامج ضع مايلي واليك النتائج :

>> [h , R , Ri] = entropy(4)

h =

1.7610

R =

0.2390

Ri =

1.8032e+003

%[h , R , Ri] = entropy(M)


function [h , R , Ri] = entropy(M)

Rs = 1024 ; % symbols/s , baud rate
PI = [0.5 0.2 0.2 0.1]'; % the probabilities of 
%symbols [p(A) p(B) p(C) p(D)]

    h = 0;  
    
    for i = 1:M  
         
                if (PI(i) == 0) h= h ;
                else    
                h = h - PI(i)*log2(PI(i));   
                end;
    end 
    

R = log2(M) - h ;  % redundancy
Ri = Rs * h  ;  % information rate of the source            
end     

لتنفيذ البرنامج ضع مايلي واليك النتائج :

>> [h , R , Ri] = entropy(4)

h =

1.7610

R =

0.2390

Ri =

1.8032e+003