Thema: ln-Funktion

Einzelnen Beitrag anzeigen

Rebel

Registriert seit: 10. Jan 2014
18 Beiträge
 
#11

AW: ln-Funktion

  Alt 4. Feb 2014, 17:48
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject); //Koordinatensystem
var i: integer;
begin
  with image1.Canvas do
  begin
  moveto(20,220); lineto(440,220); //x-Achse
  moveto(220,5); lineto(220,420); //y-Achse
  moveto(430,215); lineto (442,220);
  lineto (430,225); //x-Pfeil
  moveto(215,15); lineto (220,5);
  lineto (225,15); //y-Pfeil
  textout(445,225,'x'); //Beschriftung x
  textout(200,0,'y'); //Beschriftung y
    for i:=-10 to 10 do
    begin
    moveto(220+50*i,215);
    lineto (220+50*i,225); //x-Einteilung
    moveto(215,220+50*i);
    lineto (225,220+50*i); //y-Einteilung
    textout(222+50*i,225,inttostr(i)); //Zahlen x-Achse
    if i <> 0 then
    textout (205,213+50*i,inttostr(-i)); //Zahlen y-Achse
    end;
  end;

procedure TForm1.Button7Click(Sender: TObject); //Logarithmusfunktion, die nicht klappt :(
var float:Double; x,y:real; i,j:integer;

begin
 Val(edit1.Text,a,f1);

begin
  float:= Ln(a);
  float := Exp(float);
  i:=20;
  while i<420 do
    begin
    i:=i+1;
    x:=(i-220)/50; //x skalieren
    y:=float; //y sklarieren //Befehl Quelle: [url]http://www.physik-multimedial.de/cvpmm/sle/trigonometrie/sinusfunktion.html[/url]
    j:=round((220-y*50)); //j berechnen
    image1.Canvas.Pixels[i,j]:=clteal; //zeichnen
    image1.Canvas.Font.Color:=clteal;
    image1.Canvas.TextOut(340,405, 'y=ln(a)');
end;
end;
end;
Ich glaube mein Befehl ist einfach falsch, aber ich weiß halt nicht, wie ich ihn richtig schreiben soll
  Mit Zitat antworten Zitat