MATLAB: Inverse of algebraic expression in Matlab

equation

I need to get inverse expression of the following algebraic expression in matlab.
clc;
clear;
syms r
E(r)= 1-1/2*((1+r)*log2(1+r)+(1-r)*log2(1-r));
g=finverse(E)
Using this command no output is there. I need to see the expression of r in terms of E. Is there any way to get that. Pl somebody help me.
output is
g(r) =
Empty sym: 0-by-1

Best Answer

Possibly:
rfcn = @(E) fsolve(@(r) 1-1/2*((1+r).*log2(1+r)+(1-r).*log2(1-r)) - E, 10); % Anonymous Function: r(E)
N = 200;
Ev = linspace(0, 1, N); % Sample E’ Vector
for k = 1:numel(Ev)
r(k) = rfcn(Ev(k));
end
figure
plot(Ev, real(r), Ev, imag(r))
grid
gama = linspace(-1, 1, N);
[Gama,Rm] = ndgrid(gama,r);
G = @(r,gama) atan(r.*tan(N*gama)); %% r is [0,1];
g = @(r,gama) atan(r.*tan(gama)); %% gama is also [-1,1];
Delta=G(Rm,Gama)-N*g(Rm,Gama);
figure
meshc(gama, Ev, real(Delta))
grid on
xlabel('\gamma')
ylabel('E')
zlabel('\Delta')
view(125,25)
and:
Related Question