Could anyone help to covert the equation into matlab code

How to convert this into code?

2 Commenti

You can't convert it. YOu should write your own code
Did you try?
Yes
for i =2:N
x=1+((Pi(i).*yi(i))./1+sum(Pi*yi(3:N)));
result=log2(x);
y=sum(result);
end

Accedi per commentare.

 Risposta accettata

Not sure what arrays p and g should be.
B=sum(log(1+(p(2:n).*g(2:n))./(1+arrayfun(@(x)sum(x*g(3:n)),p(2:n))))/log(2));

7 Commenti

B=sum(log2(1+(p(2:n).*g(2:n))./(1+arrayfun(@(x)sum(x*g(3:n)),p(2:n)))));
I have tried something too .Please let me know if anything is wrong with my code.
for i =2:N
x=1+((Pi(i).*yi(i))./1+sum(Pi*yi(3:N)));
result=log2(x);
y=sum(result);
end
This should work.
result=0
for i =2:N
x=1+((Pi(i)*yi(i))/1+sum(Pi(i)*yi(3:N)));%sum works here because you are summing an array
result=result+log2(x);%must sum during the loop operation
end
result=0
for i =2:N
x=1+((Pi(i)*yi(i))/(1+sum(Pi(i)*yi(3:N))));%sum works here because you are summing an array
%needed ()around the /(1+...)
result=result+log2(x);%must sum during the loop operation
end

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by