Autor Beitrag
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Mo 27.06.05 20:15 
Hallo ich muss für die Schule die logistische Gleichung : y n+1 = a* yn *(1-yn)
programmieren und will diese deshalb auch graphisch darstellen dies funktioniert aber leider nicht, da die Graphic dann sehr gestaucht und viel zu klein aussieht, ich habe schon diverse streckfaktoren eingebaut aber mir scheint, als ob das bei dieser Art von Gleichung nicht so ganz funktioniert. hoffentlich kann mir jemand von euch helfen so sieht mein Programm bis jetzt aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
function rechnung (yn:real):real;
begin
 rechnung:=faktor*yn*(1-yn);
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
const streckfaktor_y = 600 ;
      streckfaktor_x = 1;
var counter,y:integer;
    yn,wert:real;
begin
if key = #13 then
begin
   faktor := strtofloat(edit1.text);
   wert:=rechnung(0.3);

for counter:=1 to 500 do
   begin
     Canvas.Pixels[round(counter*streckfaktor_x),(400-(round(streckfaktor_y*wert)))]:=clblack;

      wert:=rechnung(wert);


   end;

end;
end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mo 27.06.05 20:54 
Liegt wohl daran, dass die Zahlenfolge schon nach wenigen Schritten konvergiert (wenn die Formel richtig ist)... Du musst deswegen den Graphen in y-Richtung stark strecken (z.B. in y-Richtung um Faktor 100 vergrössert).
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Fr 01.07.05 21:35 
Ja das habe ich inzwischen auch gemacht kein problem mehr aber ich hätte mal ne andere Frage wie stellt man Graphen eigenlich allgemein in Delphi dar meine Lösung ist doch nicht sonderlich elegant oder?
Ich hätte noch eine weitere Frage, ich will die Wertveränderung auch von den noch weiterentfernten Werten darstellen, wie schaffe ich es, dass sich eine scrollbar habe mit der ich das sichtfled des fensters z.B. nach rechts verschieben kann.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 01.07.05 22:19 
Viel eleganter geht es nicht. Man könnte allenfalls statt Pixel Linien zeichnen.
Man könnte den Code einfach allgemein ein bisschen sauberer/strukturierter/übersichtlicher machen.
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Sa 02.07.05 19:46 
Ja habe ich inzwischen auch gemacht funktioniert einwandfrei, aber ich habe irgend wann mal ein programm gesehen, das ein richtiges Achsenkreuz hatte und ich glaube, dass war schon vorgefertigt und die entprechende Person musste die Funktion nur noch hinein zeichnen. Das sah weiß aus und hatte auch ein Linienmuster. Hier habe ich die Exe file
Einloggen, um Attachments anzusehen!
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Sa 02.07.05 19:51 
was meint ihr dazu wie könnte ich das prog noch optimieren?
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Sa 02.07.05 19:53 
wenn ihr einen z.B. einen Startwert von 0,3 und a= 3,9 eingibt wird die Funktion chaotisch.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 02.07.05 20:50 
ähm... das prog tut bei mir garnix. null. nada.
edit:
ACH MAN MUSS ENTER DRÜCKEN!
man -.- ja, stimmt, die sache wird dann etwas komisch. keine ahnung warum, aber mach nen buttpn zum zeichnen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.