תכנות נומרי עם Matlab ו-Octave/שלום עולם!: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
Atavory (שיחה | תרומות)
Atavory (שיחה | תרומות)
שורה 13:
==עבודה אינטראקטיבית==
 
===Matlab===
כדי להפעיל את המתרגם בצורת עבודה אינטראקטיבית:
פותחים את התוכנה. החלון הגדול נקרא workspace מחכים לסיום הריצה ולקבלת.
#ראשית פתח טרמניל (חלון פקודות):
#* בלינוקס, הקש Alt+F2 והקלד konsole אם הינך בסביבת KDE, או gnome-terminal אם הינך בסביבת GNOME.
#* בחלונות, הקש Win+R והקלד cmd אם הינך בחלונות NT ומעלה, או command אם הינך בחלונות ME ומטה.
#במערכת חלונות, מצא היכן מותקנת matlab/octave במחשב שלך. לרוב, אם הנך משתמש בPython 2.5, תותקן התוכנה בC:\pyton25. הקלד set path=%path%;C:\python25 (או שם הספריה במערכת שלך), והקש Enter.
#הקלד python, והקש Enter.
 
<source lang = "pythonmatlab">
כשהמתרגם עולה במצב אינטראקטיבי, הוא מדפיס ראשית הודעת ברכה כגון זו:
>>>
<div style="direction: ltr;">
<pre>
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
</pre>
</div>
(ההודעה משתנה מעט בין מערכת אחת לשניה.)
 
נשים לב לסימן
<source lang = "python">
>>>
</source>
סימןזוהי זההשורה ידועהראשונה או סימן בשם [[w:en:Command_prompt#Command_prompt|prompt]], והוא מסמן שהמתרגם ממתין לקלט.
 
===Octave===
נקליד כעת את השורה הבאה, המסמנת שברצוננו להדפיס את 'Hello, world!':
*לינוקס: פתח חלון פקודות, והקלד octave (באותיות קטנות).
<source lang = "python">
*חלונות: הפעל את התוכנה.
>>> print 'Hello, world!'
 
מיד תראה הודעת פתיחה, ולאחריה ציין:
<source lang = "pythonmatlab">
GNU Octave, version 2.9.12
Copyright (C) 2007 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.
 
Octave was configured for "i486-pc-linux-gnu".
 
Additional information about Octave is available at http://www.octave.org.
 
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html
 
Report bugs to <bug@octave.org> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).
 
For information about changes from previous versions, type `news'.
 
octave:1>
</source>
(במערכות שונות עשויה להופיע הודעה שונה מעט).
כאשר נקיש Enter, המתרגם יבצע את הפקודה, וידפיס את התוצאה המבוקשת.
 
<source lang = "python">
נשים לב לסימן
>>> print 'Hello, world!'
<source lang = "pythonmatlab">
Hello, world!
octave:1>
>>>
</source>
סימן זה ידוע בשם [[w:en:Command_prompt#Command_prompt|prompt]], והוא מסמן שהמתרגם ממתין לקלט.
לאחר ההדפסה, המתרגם ממתין לפקודה הבאה.
 
==קובץ אצווה==