%INVFCTDEMO Demonstration von Funktion und Umkehrfunktion
% am Beipiel von exp und log
xa = -4:0.01:4 ; ya = exp(xa) ;
xb = 0.01:0.01:4 ; yb = log(xb) ;
plot(xa,ya,'g') ;
axis ([-4 4 -4 4]) ; axis square ; hold on
plot(xb,yb,'b')
plot([-4 4] ,[-4 4],'r') ; % Diagonale
plot([0 0], [-4 4],'k') ; plot( [-4 4],[0 0],'k') % Achsen
% Eingabe Punkt auf einer der Kurven
disp('Bitte 5 mal mit dem Cursor einen Punkt auf einer der Kurven waehlen!')
for irep = 1:5
[xcu,ycu] = ginput(1);
if length(ycu) == 0
xcu = 2; ycu = 0.8;
end
if ycu > xcu
% Exponentialfunktion
xl(1) = xcu ; yl(1) = exp(xcu);
xl(3) = yl(1); yl(3) = log(xl(3)) ;
else
if xcu > 1
xl(1) = xcu; yl(1) = log(xcu);
xl(3) = yl(1); yl(3) = exp(xl(3)) ;
else
yl(1) = ycu; xl(1) = exp(ycu);
xl(3) = yl(1); yl(3) = exp(xl(3)) ;
end
end
xl(2) =( xl(1) + xl(3))/2; yl(2) =( yl(1) + yl(3))/2;
if irep > 1
delete( hd)
end
hd = plot(xl,yl,'-or');
end
hold off; disp('invfctdemo beendet!')