Matlab

March 13, 2023 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Matlab...

Description

‫‪ ‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬ ‫‪Introduction to Matlab Programming‬‬

‫اﻋﺪاد‪ ‬د‪/‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪاﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ‬ ‫ر ‪‬ﻴﺲ‪ ‬ﻗﺴﻢ‪ ‬هﻨﺪﺳﺔ‪ ‬ا‪‬ﻟ‪‬ﺤ‪‬ﺎ‪‬ﺳ‪‬ﺐ‪ ‬اﻵﻟﻲ‪ ‬‬ ‫آﻠﻴﺔ‪ ‬ا‪‬ﻟ‪‬ﺤ‪‬ﺎ‪‬ﺳ‪‬ﺐ‪ ‬اﻵﻟﻲ‪ ‬وﻧﻈﻢ‪ ‬اﻟﻤﻌﻠﻮﻣﺎت‪ ‬‬ ‫‪‬ﺟ‪‬ﺎ‪‬ﻣ‪‬ﻌ‪‬ﺔ ‪‬م‪ ‬اﻟﻘﺮى‪ ‬ﺑﻤﻜﺔ‪ ‬اﻟﻤﻜﺮﻣﺔ‪ ‬‬

‫ﺟﻤﻴﻊ ‪‬ﻟﺤﻘﻮق‪ ‬ﻣﺤﻔﻮﻇ‬

‫© ‪2007‬‬

‫‪ ‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ﻣﻌﻠﻮﻣﺎ ‪ ‬اﻟﻔﺼﻞ اﻷو )اﻟ ﻘﺪﻣ (‪ ‬‬ ‫)‪Information in Chapter 1 (Introduction‬‬ ‫ﻣﺆﺳﺴﻮ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬‬ ‫‪‬‬

‫آﻠﻴﻒ‪ ‬ﻣﻮﻟ‬

‫)‪ (Cleve Moler‬‬

‫ﻩﻮ ‪ ‬أﺳﺘﺎذ ‪ ‬اﻟﺮﻳﺎﺿﻴﺎت ‪ ‬وﻋﻠﻮم ‪ ‬اﻟﺤﺎﺳﺐ ‪  ‬ﻷﺁﺜﺮ ‪ ‬ﻣﻦ ‪ ‬ﻋﺸﺮﻳﻦ ‪  ‬ﻋ‪‬ﺎ‪‬ﻣ‪  ‬ﻓﻲ ‪ ‬ﺟﺎﻣﻌﺔ ‪ ‬ﻣﺘﺸﻴﺠﻴﻦ ‪ ‬وﺟﺎﻣﻌﺔ ‪ ‬ﺳﺘﺎﻧﻔﻮرد ‪ ‬وﺟﺎﻣﻌﺔ ‪ ‬ﻧﻴﻮﻣﻜﺴﻴﻜﻮ ‪ ‬‬ ‫وﻗﺪ أﻣﻀﻰ‪ ‬ﺧﻤﺲ‪ ‬ﺳﻨﻮات‪ ‬ﻋﻨﺪ‪ ‬اﺛﻨ ﻦ‪ ‬ﻣﻦ‪ ‬ﻣﺼﻨﻌﻲ‪ ‬اﻟــ ‪  Hardware‬وﻩﻤﺎ‪ Intel Hypercube organization  ‬و ‪ Ardent‬ﻗﺒﻞ‪ ‬أن‬ ‫ﻳﻘﻮم‪ ‬ﺑﺎﻻﻧﺘﻘﺎل‪ ‬إﻟﻰ‪  ‬ﺷﺮﺁﺔ ‪  Mathworks‬اﻟﺸﺮﺁﺔ‪ ‬اﻷم‪ ‬ﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼ ‪  ‬ﺁﻤﺎ‪ ‬أﻧﻪ‪  ‬ﻩﻮ‪ ‬اﻟﻤﺆﻟﻒ‪ ‬ﻷول‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬ﻟﻠﻤﺎﺗﻼ ‪ .‬‬ ‫‪‬‬

‫ﺟﺎك‪ ‬ﻟﻴﻞ )‪ (jack little‬‬

‫ﻩﻮ ‪ ‬اﻟﻤﺆﺳﺲ ‪  ‬ﻟﺸﺮﺁﺔ ‪   Mathworks‬ﺁﻤﺎ ‪ ‬أﻧﻪ ‪ ‬اﻟﻤﺴﺎﻋﺪ ‪ ‬ﻓﻲ ‪ ‬وﺿﻊ ‪  ‬ﺨ‪‬ﻄ‪‬ﻴ‪‬ﻂ ‪ ‬ﺑﺮﻧﺎﻣﺞ ‪ ‬اﻟﻤﺎﺗﻼ ‪  ‬وﻩﻮ ﺣﺎﺻﻞ ‪ ‬ﻋﻠﻰ ‪ ‬ﺑﻜﺎﻟﻮرﻳﻮس‬ ‫اﻟﻬﻨﺪﺳﺔ ‪ ‬اﻟﻜﻬﺮﺑﻴﺔ ‪ ‬وﻋﻠﻮم ‪ ‬اﻟﺤﺎﺳﺐ ‪ ‬ﻣﻦ ‪ ‬ﺟﺎﻣﻌﺔ ‪  MIT ‬ﻋﺎ ‪   1978‬ﺁﻤﺎ ‪ ‬أﻧﻪ ‪ ‬ﺣﺼﻞ ‪ ‬ﻋﻠﻰ ‪ ‬ﺷﻬﺎدة ‪  M.S.E.E‬ﻣﻦ ‪ ‬ﺟﺎﻣﻌﺔ ‪ ‬ﺳﺘﺎﻧﻔﻮرد ‪ ‬ﻋﺎم‬ ‫‪ . 1980‬‬

‫ﺗ‪ ‬ﺎرﻳﺦ‪ ‬اﻟﻤﺎﺗﻼب‬ ‫ﻓﻲ ‪ ‬ﻣﻨﺘﺼﻒ ‪ ‬اﻟﺴﺒﻌﻴﻨﺎت ‪ ‬ﻋﺎم ‪  1970‬ﻗﺎم ‪  ‬ﺁﻠﻴﻒ ‪ ‬ﻣﻮﻟﺮ اﻟﺬي ‪  ‬ﺁﺎن ‪ ‬رﺋﻴﺴﺎ ‪ ‬ﻟﻘﺴﻢ ‪ ‬ﻋﻠﻮم ‪ ‬اﻟﺤﺎﺳﺐ ‪ ‬ﻓﻲ ﺟﺎﻣﻌﺔ ‪ ‬ﻧﻴﻮﻣﻜﺴﻴﻜﻮ ‪ ‬وﻋﺪد ‪ ‬ﻣﻦ‬ ‫زﻣﻼﺋﻪ‪ ‬ﺑﺘﻄﻮﻳﺮ‪ ‬ﻣﻜﺘﺒﺎت‪ ‬اﻟﻔﻮرﺗﺮان‪ ‬واﻟﺘﻲ‪  ‬ﺁﺎﻧﺖ‪ ‬ﺗﺪﻋﻰ‪ LINPACK EISPACK  ‬ﺗﺤﺖ‪ ‬ﻣﻨﺤﺔ‪ ‬ﻣﻦ‪ ‬اﻟﻤﺆﺳﺴﺔ‪ ‬اﻟﻘﻮﻣﻴﺔ‪ ‬ﻟﻠﻌﻠﻮ ‪.‬‬ ‫‪‬‬

‫‪ ‬‬ ‫‪‬‬

‫‪‬‬

‫‪ ‬‬ ‫‪‬‬

‫‪ ‬‬ ‫‪‬‬

‫‪  EISPACK  LINPACK ‬ﻩﻤﺎ‪ ‬اﻟﻠﺒﻨﺔ‪ ‬اﻟﺒﺮﻣﺠﻴﺔ‪ ‬اﻷﺳﺎﺳﻴﺔ‪ ‬ﻓﻲ‪ ‬ﺑﺮﻣﺠﻴﺎت‪ ‬ﺣﺴﺎﺑﺎت‪ ‬اﻟﻤﺼﻔﻮﻓﺎ‬

‫‪.‬‬

‫ﺑﺪأ‪  ‬ﺁﻠﻴﻒ‪ ‬ﺑﻜﺘﺎﺑﺔ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬ﻟﻠﻮﺻﻮل‪ ‬إﻟﻰ‪ EISPACK ‬و‪ LINPACK ‬ﺑﻜﻞ‪ ‬ﺑﺴﺎﻃﺔ‪ ‬وﺳﻤﻲ‪ ‬ﺑﺮﻧﺎﻣﺠﻪ‪ MATLAB  ‬واﻟﺘﻲ‪ ‬ﺗﻌﻨﻲ‬ ‫)‪ (Matrix Laboratory‬أي‪ ‬ﻣﺨﺘﺒﺮ‪ ‬اﻟﻤﺼﻔﻮﻓ ‪.‬‬ ‫اﻧﺘﺸﺮ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬ﻟﻠﺠﺎﻣﻌﺎت‪ ‬اﻷﺧﺮى‪ ‬ووﺟﺪ‪  ‬ﻩﺬا‪ ‬اﻟﺒﺮﻧﺎﻣﺞ‪ ‬ﺟﻤﻬﻮر‪ ‬ﻗﻮي‪ ‬ﻣﻦ‪ ‬ﻗﺒﻞ‪ ‬اﻟﻤﺨﺘﺼﻴﻦ‪ ‬ﺑﺎﻟﺮﻳﺎﺿﻴﺎت‪ ‬اﻟﺘﻄﺒﻴﻘﻴ ‪.‬‬

‫ﻓﻲ‪ ‬ﻋﺎم ‪ 1983‬ﻋﺮض‪ ‬ﻋﻠﻰ‪ ‬اﻟﻤﻬﻨﺪس‪ ‬ﺟﻮن‪ ‬ﻟﻴﺘﻞ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬أﺛﻨﺎ ‪ ‬زﻳﺎر ‪ ‬ﻣﻮﻟﺮ‪ ‬ﻟﺠﺎﻣﻌﺔ‪ ‬ﺳﺘﺎﻧﻔﻮرد ‪ ‬وﺑﻌﺪ‪ ‬ذﻟﻚ‪ ‬اﻧﻈﻢ‪ ‬ﻟﻴﺘﻞ‪ ‬إﻟﻰ‬ ‫ﻣﻮﻟﺮ‪ ‬وﺳﺘﻴﻒ‪ ‬ﺑﺎﻧﺠﺮت‪ ‬وأﻋﻴﺪت‪  ‬ﺁﺘﺎﺑﺔ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬ﺑﻠﻐﺔ‪ ‬اﻟﺴﻲ ‪.‬‬

‫‪ ‬‬ ‫‪‬‬

‫أﺳ ﺖ ﻓﻲ‪ ‬ﻋﺎم ‪ 1984‬ﺷﺮﺁ ‪ Mathworks‬ﻟﻤﻮاﺻﻠﺔ‪ ‬ﺗﻄﻮﻳ ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼ‬

‫‪.‬‬

‫‪ ‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪1‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﺗﺎﺑﻊ‪ ‬ﻣﻠﺨﺺ ﻣﻌﻠﻮﻣﺎ ‪ ‬اﻟﻔﺼﻞ اﻷو )اﻟ ﻘﺪﻣ (‪ ‬‬ ‫)‪Information in Chapter 1 (Introduction‬‬

‫ﺗﻌﺮﻳﻒ اﻟﻤﺎﺗﻼ ‪ ‬‬ ‫‪‬‬

‫‪ ‬ﻟﻐﺔ ‪ ‬ذات ‪ ‬ﻣﺴﺘﻮى ‪ ‬ﻋﺎﻟﻲ ‪ ‬ﻟﻠﺤﺴﺎﺑﺎت ‪ ‬واﻟﺒﺮﻣﺠﺔ ‪ ‬وﺗﻤﺘﺎز ‪ ‬ﺑﻮﺟﻮد ‪ ‬ﺑﺮاﻣﺞ ﺗ ﻬﻞ ‪ ‬ﻋﻤﻠﻴﺔ ‪ ‬اﻟﺘﻌﺎﻣﻞ ‪ ‬ﻣﻊ ‪  ‬ﻩﺬﻩ ‪ ‬اﻟﻠﻐ‬

‫اﻟﻤﺎﺗ ب ‪ ‬‬ ‫اﻟﺒﺮاﻣﺞ‪ ‬ﻋﻠﻰ‪: ‬‬

‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬

‫ﺗ ﻤﻞ‬

‫اﻟﺤﺴﺎﺑﺎت‪ ‬اﻟﺮﻳﺎﺿﻴﺔ ‪ ‬‬ ‫ﺗﻄﻮﻳﺮ‪ ‬اﻟﺨﻮارزﻣﻴﺎت ‪ ‬‬ ‫ﻣﻌﺎﻟﺠﺔ‪ ‬اﻟﺒﻴﺎﻧﺎت ‪ ‬‬ ‫اﻟﻨﻤﺬﺟﺔ‪  ‬واﻟﻤﺤﺎﺁﺎة ‪ ‬وﺗﺼﻤﻴﻢ‪ ‬اﻟﻤﺨﻄﻄﺎت‪ ‬اﻷوﻟﻴﺔ‪ ‬ﻟﻠﻤﺸﺎرﻳﻊ ‪ ‬‬ ‫ﺗﺤﻠﻴﻞ‪ ‬اﻟﺒﻴﺎﻧﺎت‪  ‬ﻋﺮﺿﻬﺎ ‪ ‬‬ ‫ﻋﻤﻞ‪ ‬اﻟﺮﺳﻮﻣﺎت‪ ‬اﻟﻬﻨﺪﺳﻴﺔ‪ ‬واﻟﻌﻠﻤﻴﺔ ‪ ‬‬ ‫ﺗﻄﻮﻳﺮ‪ ‬اﻟﺘﻄﺒﻴﻘﺎت‪ ‬ﺿﻤﻦ‪ ‬واﺟﻬﺎت‪ ‬ﻣﻦ‪ ‬ﻧﻮ )‪(GUI‬‬

‫‪ ‬‬ ‫‪‬‬

‫‪ ‬‬ ‫‪‬‬

‫وﻳﻌﺘﻤﺪ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬ﻋﻠﻰ‪ ‬ﺗﻨﺴﻴﻖ‪ ‬اﻟ ﺎﻧﺎت‪ ‬ﻓﻲ‪ ‬ﺻﻮرة‪ ‬ﻣﺼﻔﻮﻓﺎت‪ ‬وﻳﻜﻮن‪ ‬اﻟﺒﺮﻧﺎﻣﺞ‪ ‬ﻣﺜﻞ‪ ‬أﻏﻠ ‪  ‬ﻐﺎت‪ ‬اﻟﺒﺮﻣﺠ ‪.‬‬

‫ﻳﺸﻤﻞ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬ﻋﻠﻰ‪ ‬ﻣﺠﻤﻮﻋﺔ‪ ‬ﻣﻦ‪ ‬ا ﺒﺮاﻣﺞ‪ ‬واﻟﺘﻲ‪ ‬ﺗﺪﻋﻰ )‪  (toolbox‬ﻣﻤﺎ‪ ‬ﻳﺘﻴﺢ‪ ‬ﻟﻚ‪ ‬اﻟﺘﻌﺎﻣﻞ‪ ‬ﻣﻊ‪ ‬اﻟ ﻄﺒﻴﻘﺎت‪ ‬اﻟﻤﺘﺨﺼﺼﺔ‪  ‬وﻩﺬﻩ‬ ‫اﻷدوات‪ ‬ﻋﺒﺎرة‪ ‬ﻋﻦ‪ ‬ﺑﺮاﻣﺞ‪ ‬ﻓﻲ‪ ‬ﺻﻮرة )‪. (M-files‬‬

‫‪ ‬‬

‫ﺗﻄﺒﻴﻘﺎت‪ ‬اﻟﻤﺎﺗﻼب‪ ‬‬ ‫‪‬‬

‫ﻓﻲ‪ ‬اﻟﻤﺠﺎل‪  ‬اﻷﺁﺎدﻳﻤﻲ ‪ :‬‬

‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪‬‬

‫ﻋﻤﻞ‪ ‬اﻟﺘﻔﺎﺻﻴﻞ‪ ‬واﻟﺘﻜﺎﻣﻞ ‪ ‬‬ ‫ﺣﻞ‪ ‬اﻟﻤﻌﺎدﻻت‪ ‬اﻟﺠﺒﺮﻳﺔ )‪ (Algebraic Equations‬‬ ‫ﺣﻞ‪ ‬اﻟﻤﻌﺎدﻻت‪ ‬اﻟﺘﻔﺎﺿﻠﻴﺔ‪ ‬ذات‪ ‬اﻟﺮﺗﺐ‪ ‬اﻟﻌﻠﻴ )‪ (Differential Equations‬‬ ‫ﻋﻤﻞ‪ ‬اﻟﺘﻔﺎﺿﻞ‪ ‬اﻟﺠﺰﺋﻲ ‪ ‬وﻋﻤﻠﻴﺎت‪ ‬اﻟﻜﺴﺮ‪ ‬اﻟﺠﺰﺋ )‪(Partial fraction‬‬

‫اﻟﻤﺠﺎﻻت‪ ‬اﻟﺘﻄﺒﻴﻘﻴﺔ ‪:‬‬

‫‪ ‬‬

‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬

‫أﻧﻈﻤﺔ‪ ‬اﻟﺘﺤﻜﻢ‪ ‬ﻓﻲ‪ ‬ﺟﻤﻴﻊ‪ ‬اﻟﻤﺠﺎﻻت‪ ‬اﻟﻬﻨﺪﺳﻴﺔ )‪(Control System‬‬ ‫ﻣﻌﺎﻟﺠﺔ‪ ‬اﻟﺼﻮ ‪ ‬‬ ‫ﻣﺤﺎﺁﺎة‪ ‬اﻹﻟﻜﺘﺮوﻧﺎ ‪ ‬‬ ‫ﻣﺠﺎل‪ ‬ﺻﻨﺎﻋﺔ‪ ‬اﻟﺴﻴﺎرا ‪ ‬‬ ‫ﻣﺠﺎل‪ ‬اﻟﻄﻴﺮان‪ ‬واﻟﺪﻓﺎع‪ ‬اﻟﺠﻮ ‪ ‬‬ ‫ﻣﺠﺎل‪ ‬اﻟﺮوﺑﻮ ‪ ‬‬

‫وﻩﻨﺎك‪ ‬اﻟﻜﺜﻴﺮ‪ ‬واﻟﻜﺜﻴﺮ‪ ‬ﻣﻦ‪ ‬اﻟﺘﻄﺒﻴﻘﺎت‪ ‬اﻟﻬﻨﺪﺳﻴﺔ ‪ .‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪2‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ﻣﻌﻠﻮﻣﺎ ‪ ‬اﻟﻔﺼﻞ اﻟﺜﺎﻧ )واﺟﻬﺔ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼ (‪ ‬‬ ‫)‪Information in Chapter 2 (Matlab Desktop‬‬ ‫‪‬‬

‫واﺟﻬﺔ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪ ‬ﺗﻜﻮن‪ ‬ﻣ‬

‫‪ :‬‬

‫‪ o‬ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ )‪ (Command Window‬‬ ‫‪ o‬ﻣﻨﻄﻘﺔ‪ ‬اﻟﻌﻤﻞ )‪ (Workspace‬‬ ‫‪ o‬ﻧﺎﻓﺬة‪ ‬ﺗﺴﺠﻴﻞ‪ ‬اﻻواﻣﺮ )‪ (Command History‬‬ ‫‪‬‬

‫ﺷﺮﻳﻂ‪ ‬اﻟﻘﻮاﺋ ‪ ‬وﺗﺘﻜﻮن‪ ‬ﻣ‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬

‫‪ :‬‬

‫ﻗﺎﺋﻤ ‪ ‬ﻣﻠﻒ )‪ (File‬‬ ‫ﻗﺎﺋﻤﺔ‪ ‬اﻟﺘﻌﺪﻳﻞ )‪ (Edit‬‬ ‫ﻗﺎﺋﻤﺔ )‪ (Debug‬‬ ‫ﻗﺎﺋﻤﺔ )‪ (Desktop‬‬ ‫ﻗﺎﺋﻤﺔ )‪ (Window‬‬

‫‪ o‬ﻗﺎﺋﻤﺔ )‪ (Help‬‬

‫‪‬‬

‫ﻣﺤﺘﻮﻳﺎت‪ ‬ﻗﺎﺋﻤ‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬ ‫‪o‬‬

‫‪ ‬ا ﻤﺴﺎﻋﺪة )‪ :(Help‬‬

‫ﻗﺎﺋﻤﺔ اﻟﻤﺤﺘﻮﻳﺎ )‪ (Contents‬‬ ‫ﻗﺎﺋﻤﺔ اﻟﻔﻬﺮ )‪ (Index‬‬ ‫ﻗﺎﺋﻤﺔ اﻟﺒﺤﺚ )‪ (Search‬‬ ‫ﻗﺎﺋﻤﺔ )‪ (Demos‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪3‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ‪‬واﻣﺮ اﻟﻔﺼﻞ ا ﺜﺎﻟ )اﻟ ﺎﺗﻼب‪ ‬آ ‪‬ﻟﺔ‪ ‬ﺣﺎﺳﺒ (‪ ‬‬ ‫)‪Matlab Examples in Chapter 3 (Matlab as a Calculator‬‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬

‫ﺗﻨﻔﻴﺬ اﻟﻤﺜﺎ ﻓ ‪ ‬اﻟﻤﺎﺗﻼ‬

‫ﺑﻌﺾ‪ ‬اﻟﻌﻤﻠﻴﺎت‪ ‬اﻟﺮﻳﺎﺿﻴﺔ‪ ‬اﻟﺒﺴﻴﻄﺔ‬

‫>>‬ ‫‪>>6+2‬‬ ‫‪6+2‬‬ ‫‪>>6-2‬‬ ‫‪>>6*2‬‬ ‫‪>>6/2 ‬‬

‫‪Some math operations‬‬

‫اﺳﺘﺨﺪام‪ ‬اﻟﻤﺎﺗﻼب‪ ‬‬ ‫ﺁﺂﻟﺔ‪ ‬ﺣﺎﺳﺒﺔ‪ ‬‬ ‫‪Operations on‬‬ ‫‪ Variables‬‬

‫اﻟﺪاﻟﺔ‪ ‬اﻷﺳﻴﺔ‪ ‬ﻟﻸﺳﺎس ‪e‬‬ ‫‪Exponential Function‬‬ ‫اﻟﺪاﻟﺔ‪ ‬اﻟﻠﻮﻏﺎرﺗﻤﻴﺔ‪ ‬اﻟﻄﺒﻴﻌﻴﺔ‬ ‫‪ Natural Logarithm‬‬ ‫‪Logarithm‬‬ ‫اﻟﺠﺬر‪ ‬اﻟﺘﺮﺑﻴﻌﻲ‬ ‫‪Square Root‬‬ ‫اﻟﺪاﻟﺔ‪ ‬اﻟﻠﻮﻏﺎرﺗﻤﻴﺔ‪ ‬ﻟﻸﺳﺎس ‪10‬‬ ‫‪Base 10 Logarithm‬‬ ‫اﻟﻘﻴﻤﺔ‪ ‬اﻟﻤﻄﻠﻘﺔ‬ ‫‪Absolute Value‬‬ ‫اﻟﺪاﻟﺔ‪ (sin) ‬ﺑﺎﻟﺮادﻳﺎ ‪ ‬‬

‫‪>>exp(1) ‬‬ ‫‪>>log(1) ‬‬ ‫‪>>sqrt(36) ‬‬

‫ﻣﻼﺣﻈﺎت‪ ‬‬ ‫‪ Notes‬‬ ‫‪ ‬‬

‫ﺣﺴﺎب ﻗﻴﻤﺔ اﻟﺪاﻟﺔ‪ ‬اﻷﺳﻴﺔ‪ ‬ﻟﻸﺳﺎس )‪(e‬‬ ‫ﻟﻠﻌﺪد‪  (1) ‬‬ ‫ﺣﺴﺎب ﻗﻴﻤﺔ ا ﺪاﻟﺔ‪ ‬اﻟﻠﻮﻏﺎرﺗﻤﻴﺔ‪ ‬اﻟﻄﺒﻴﻌﻴﺔ‬ ‫ﻟﻠﻌﺪد‪  (1) ‬‬ ‫ﺣﺴﺎب‪ ‬اﻟﺠﺬر‪ ‬اﻟﺘﺮﺑﻴﻌﻲ‪ ‬ﻟﻠﻌﺪد )‪  (36‬‬

‫‪>>abs(-100) ‬‬

‫ﺣﺴﺎب‪ ‬اﻟﻘﻴﻤﺔ‪ ‬اﻟﻤﻄﻠﻘﺔ‪ ‬ﻟﻠﻌﺪد )‪(-100‬‬

‫‪>>sin(pi/2) ‬‬

‫ﺣﺴﺎب‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﺪاﻟﺔ )‪ (sin‬ﻟﻠﻌﺪد )‪( π   /2‬‬

‫‪>>sind(90) ‬‬

‫ﺑﺎﺣﻟﺴﺮﺎادﻳ‬ ‫بﺎ‪ ‬ﻗنﻴﻤﺔ‪ ‬اﻟﺪا ﺔ )‪ (sin‬ﻟﻠﻌﺪد )‪(90‬‬

‫ﺑﺎﻟﺪرﺟﺎت‬ ‫ﺣﺴﺎب‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﺪاﻟﺔ )‪ (cos‬ﻟﻠﻌﺪد ) ‪( π  ‬‬ ‫‪>>cos(pi) ‬‬ ‫ﺑﺎﻟﺮادﻳﺎن‬ ‫‪ >>atan(pi) ‬ﺣﺴﺎب‪ ‬ﻗﻴﻤﺔ‪ ‬داﻟﺔ‪ ‬ﻣﻌﻜﻮس )‪ (tan‬ﻟﻠﻌﺪد‬ ‫)‪(100‬‬

‫‪>>sec(pi) ‬‬ ‫‪>>sinh(100) ‬‬ ‫‪>>sin(abs(sqrt(90)))  ‬‬

‫‪about‬ت‪ ‬ﻋﻦ‪ ‬داﻟﺔ‪ ‬ﻣﻌﻴﻨﺔ‬ ‫ا‪a‬ﻟﻤﻌﻠﻮﻣﺎ‬ ‫‪Information‬‬ ‫‪ Matlab Function‬‬

‫>>‬ ‫‪>>help‬‬ ‫‪help sqrt‬‬ ‫>>‬ ‫‪>>help‬‬ ‫‪help sin ‬‬

‫ﻣﻌﻠﻮﻣﺎت ﻣﻄﻮﻟ ‪ ‬ﻋﻦ‪ ‬داﻟﺔ‪ ‬ﻣﻌﻴﻨ‬

‫‪>>doc sind ‬‬

‫‪Information about a‬‬ ‫‪ Matlab Function‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫إﺟﺮا ‪ ‬ﺑﻌﺾ‪ ‬اﻟﻌﻤﻠﻴﺎت‪ ‬اﻟﺮﻳﺎﺿﻴﺔ‬ ‫اﻟﺒﺴﻴﻄﺔ‪  ‬وﻩﻲ‪ ‬ﺑﺎﻟﺘﺮﺗﻴﺐ‪ ‬اﻟﺠﻤﻊ‪ ‬ﺛﻢ‪ ‬اﻟﻄﺮح‪ ‬‬ ‫ﺛﻢ‪ ‬اﻟﻀﺮب‪ ‬ﺛﻢ‪ ‬اﻟﻘﺴﻤﺔ‪  ‬‬

‫‪ >>log10(20) ‬ﺣﺴﺎب ﻗﻴﻤﺔ اﻟﺪاﻟﺔ‪ ‬اﻟﻠﻮﻏﺎرﺗﻤﻴﺔ‪ ‬ﻟﻸﺳﺎس‬ ‫)‪ (10‬ﻟﻠﻌﺪد )‪  (20‬‬

‫‪Sine Function in Radians‬‬ ‫اﻟﺪاﻟﺔ‪ (sin) ‬ﺑﺎﻟﺪرﺟﺎ ‪ ‬‬ ‫‪Sine Function in Degrees‬‬ ‫اﻟﺪاﻟﺔ‪ (cos) ‬ﺑﺎﻟﺮادﻳﺎ ‪ ‬‬ ‫)‪Cosine Function (Radians‬‬ ‫داﻟﺔ‪ ‬ﻣﻌﻜﻮ )‪ (tan‬‬ ‫‪Tangent Inverse Function‬‬ ‫اﻟﺪاﻟﺔ )‪ (sec‬‬ ‫‪Secant Function‬‬ ‫اﻟﺪاﻟﺔ )‪  (sinh‬‬ ‫‪Hyperbolic Sine Function‬‬ ‫ﺣﺴﺎب‪ ‬داﻟﺔ‪ ‬داﺧﻞ‪ ‬داﻟﺔ‪ ‬أﺧﺮى‪ ‬‬ ‫‪Command Nesting‬‬

‫ﺷﺮ ‪ ‬اﻟﻤﺜﺎ‬

‫‪4‬‬

‫ﺣﺴﺎب‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﺪاﻟﺔ )‪ (sec‬ﻟﻠﻌﺪد ) ‪( π  ‬‬ ‫ﺣﺴﺎب‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﺪاﻟﺔ )‪ (sinh‬ﻟﻠﻌﺪد )‪(100‬‬

‫ﻳﻤﻜﻦ ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼب ﺣﺴﺎب اﻟﺪاﻟﺔ‪ ‬ﻟﺪاﻟﺔ‬ ‫أﺧﺮى‪  ‬وﻩﻜﺬا‪ ‬ﻣﻊ ﺿﺮورة‪ ‬ﻣﺮاﻋﺎ ﻋﺪد‬ ‫اﻷﻗﻮاس‪  ‬‬ ‫ﻟﻠﺤﺼﻮل‪ ‬ﻋﻠ ‪ ‬ﻣﻌﻠﻮﻣﺎت‪ ‬ﻣﻔﺼﻠﺔ‪ ‬ﻋﻦ‬ ‫داﻟﺔ‪ ‬اﻟﻤﺎﺗﻼب )‪ (sqrt‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬ﻟﻠﺪاﻟﺔ‬ ‫)‪  (sin‬وﺗﺸﻤﻞ‪ ‬ﻣﻌﻠ ﻣﺎت اﻟﺘﻌﺮﻳﻒ‬ ‫وﺁﻴﻔﻴﺔ‪ ‬اﻻﺳﺘﺨﺪام‪ ‬وﻏﻴﺮ‪ ‬ذﻟ ‪ ‬‬ ‫ﻟﻠﺤﺼﻮل‪ ‬ﻋﻠ ‪ ‬ﻣﻌﻠﻮﻣﺎت ﻣﻄﻮﻟ ‪ ‬ﻋﻦ‬ ‫داﻟﺔ‪ ‬اﻟﻤﺎﺗﻼب )‪ (sind‬ﻣﺜﻞ‪ ‬اﻟﺘﻌﺮﻳﻒ‬ ‫وﺁﻴﻔﻴﺔ‪ ‬اﻻﺳﺘﺨﺪام‪ ‬وﻧﺤﻮﻩ‪  ‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

 

 ‫ﺑﺎﻟﻤﺎﺗﻼب‬ ‫اﻟﺒﺮﻣﺠﺔ‬ ‫ﻓﻲ‬ ‫ﻣﻘﺪﻣﺔ‬

Introduction to Matlab

  Matlab Function

exp xp(( x) l og( x) l og10( x) sqrt(x)

Matlab Function

cos(x) s i n( x) t a n( x ) aco cos( s( x) as i n( x) at an( x) cot(x) c sc ( x ) sec(x) acot(x) acsc(x) ase sec( c( x) at an2( y, x)

Matlab Function

cosh(( x) cosh si nh( x) t anh( x) aco cosh sh(( x) asi nh( x) at anh( x) coth(x) csch csc h( x) sech se ch(( x) aco cott h( x) acsch csch(( x) asech sech(( x)

Dr. Khalid A. Al-Hindi

‫اﻟﻤﺎﺗ‬ ‫ﻓﻲ ﺑﺮﻧﺎﻣﺞ‬ ‫اﻟﺮﻳﺎﺿﻴﺔ اﻟﻤﻌﺮﻓﺔ‬ ‫ل ﻟﺒﻌﺾ اﻟﺪوال‬‫و‬‫ﺪ‬‫ﺟ‬ Exponential and Logarithmic Functions Definition Mathematical Form  x Exponential e  

 Natural logarithm Common (base 10) logarithm Square root Trigonometric Functions Definition Cosine Sine Tangent Inverse cosine Inverse sine Inverse tangent Cotangent Cosecant Secant Inverse cotangent Inverse cosecant Inverse secant Four-quadrant inverse tangent. Hyperbolic Functions Definition Hyperbolic cosine Hyperbolic sine

Hyperbolic tangent Inverse hyperbolic cosine Inverse hyperbolic sine Inverse hyperbolic tangent Hyperbolic cotangent Hyperbolic cosecant Hyperbolic secant Inverse hyperbolic cotangent Inverse hyperbolic cosecant Inverse hyperbolic secant

5

ln( x) log( x)  x  

Mathematical Form cos( x) sin( x) tan( x)   –1 cos ( x)  –1 sin ( x)  –1 tan ( x) cot( x) csc( x) sec( x)  –1 cot ( x)  –1 csc ( x)  –1 sec ( x)

Mathematical Form cosh( x) sinh( x) tanh(  –1 x) cosh ( x)  –1 sinh ( x)  –1 tanh ( x) coth( x) csch( x) sech( x)  –1 coth ( x)  –1 csch ( x)  –1 sech ( x)

  ‫اﻟﻬﻨﺪ‬ ‫اﻟﺤﻤﻴﺪ‬ ‫ﻋﺒﺪ‬ ‫ ﺧﺎﻟﺪ‬/‫د‬ ‫اﻋﺪاد‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ اﻟﺮاﺑ )اﻟ ﺘﻐﻴﺮا (‪ ‬‬ ‫)‪Matlab Examples in Chapter 4 (Variables‬‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮ‪ ‬‬ ‫‪Defining a‬‬ ‫‪Variable‬‬

‫ﻃﺮﻳﻘﺔ اﻟﺘﻌﺮﻳ ‪ ‬‬

‫اﻟﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‬ ‫اﻟﻤﺘﻐﻴﺮات‪ ‬‬ ‫‪Operations on‬‬ ‫‪ Variables‬‬

‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬ ‫‪>>a=2‬‬ ‫>>‬ ‫‪>>b=10‬‬ ‫‪b=10 ‬‬

‫ﻣﻼﺣﻈﺔ‪  ‬ﻩﺎﻣ ‪ ‬‬

‫>>‬ ‫‪ A=3‬‬ ‫‪ A=3 ‬‬

‫إﻧﺸﺎ ‪ ‬ﺛﻼث‪ ‬ﻣﺘﻐﻴﺮات‬

‫>>‬ ‫;‪ A=6‬‬ ‫;‪ A=6‬‬

‫‪ Defining three variables‬‬ ‫أﻣﺜﻠﺔ‪ ‬ﻟﻌﻤﻠﻴﺎت‪ ‬رﻳﺎﺿﻴﺔ‪ ‬‬ ‫‪Examples of Simple Math‬‬ ‫‪Operations‬‬

‫>>‬ ‫;‪>>C=3‬‬ ‫‪C=3; ‬‬ ‫‪>>A+B+C ‬‬ ‫‪>>(A*B)/C ‬‬ ‫‪>>A^2+B^2 ‬‬ ‫‪>>(sin(A)+cos(B))/2  ‬‬

‫اﻟﻤﺜﺎل‪ ‬اﻷول‪ ‬ﻟﻠﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‪ ‬اﻟﻤﺘﻐﻴﺮا‬ ‫اﻟﻤﺜﺎل‪ ‬اﻟﺜﺎﻧﻲ‪ ‬ﻟﻠﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‪ ‬اﻟﻤﺘﻐﻴﺮا‬ ‫اﻟﻤﺜﺎل‪ ‬اﻟﺜﺎﻟﺚ‪ ‬ﻟﻠﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‪ ‬اﻟﻤﺘﻐﻴﺮا‬ ‫اﻟﻤﺜﺎل‪ ‬اﻟﺮاﺑﻊ‪ ‬ﻟﻠﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‪ ‬اﻟﻤﺘﻐﻴﺮا‬ ‫اﻟﻌﺪد‪ ‬اﻟﺘﺨﻴﻠﻲ )‪ (i‬ﻣﻌﺮف‪ ‬ﻣﺴﺒﻘﺎ‪ ‬ﻓﻲ‬ ‫‪ >>i ‬اﻟﻤﺎﺗﻼب‪ ‬ﺑﺸﺮط‪ ‬أن‪ ‬ﻻ‪ ‬ﻳﺘﻢ‪ ‬اﻋﺎدة‪ ‬ﺗﻌﺮﻳﻒ‪ ‬‬ ‫اﻟﻤﺘﻐﻴﺮ‪ (i) ‬أﺛﻨﺎ ‪  ‬ﺁﺘﺎﺑﺔ‪ ‬أي‪ ‬ﺑﺮﻧﺎﻣﺞ ‪ ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮﻳﻦ‪  ‬ﻣﺮﺁﺒﻴﻦ‬ ‫‪Defining two complex‬‬ ‫‪ numbers‬‬

‫>>‬ ‫‪>>a=a+i‬‬ ‫‪a=a+i  ‬‬ ‫‪>>b=a+2i‬‬

‫ﺑﻌﺾ‪ ‬اﻟﻌﻤﻠﻴﺎت‪ ‬اﻟﺮﻳﺎﺿﻴﺔ‪ ‬ﻋﻠﻰ‬ ‫اﻟﻤﺘﻐﻴﺮﻳﻦ‪  ‬اﻟﻤﺮﺁﺒﻴﻦ‬

‫>>‬ ‫‪>>a+b‬‬ ‫‪a+b‬‬

‫‪Extra Matlab‬‬ ‫‪ Commands‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮﻳﻦ‪  ‬ﻣﺮﺁﺒﻴﻦ )‪ (a‬و )‪ ( b‬‬

‫>>‬ ‫‪>>a-b‬‬ ‫‪a-b ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮ‪  ‬ﻣﺮﺁﺐ‬

‫>> إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮ‪  ‬ﻣﺮﺁﺐ )‪  (z‬‬ ‫‪>>z=3+4i‬‬ ‫‪z=3+4i ‬‬

‫‪Defining a complex‬‬ ‫‪ number ‬‬ ‫اﻟﺠﺰ ‪ ‬اﻟﺤﻘﻴﻘﻲ‪ ‬ﻟﻤﺘﻐﻴﺮ‪  ‬ﻣﺮﺁﺐ‬ ‫‪Real part of a complex‬‬ ‫‪ number ‬‬ ‫اﻟﺠﺰ ‪ ‬اﻟﺘﺨﻴﻠﻲ‪ ‬ﻟﻤﺘﻐﻴﺮ ﻣﺮﺁ‬ ‫‪Imaginary part of a‬‬ ‫‪ complex number ‬‬ ‫زاوﻳﺔ‪ ‬اﻟﻄﻮر‪ ‬ﻟﻤﺘﻐﻴﺮ‪  ‬ﻣﺮﺁﺐ‬ ‫‪Phase angle of a complex‬‬ ‫‪ number in radians‬‬ ‫اﻟﻘﻴﻤﺔ‪ ‬اﻟﻤﻄﻠﻘﺔ‪ ‬ﻟﻤﺘﻐﻴﺮ‪ ‬ﻣ ﺮﺁ‬ ‫‪Absolute value of a‬‬ ‫‪complex number‬‬ ‫ﻋﺮض‪ ‬اﻟﻤﺘﻐﻴﺮات‪ ‬اﻟﻤﺴﺘﺨﺪﻣﺔ‪ ‬‬ ‫‪Display Variables‬‬ ‫ﻋﺮض‪ ‬ﻣﻔﺼﻞ‪ ‬ﻟﻠﻤﺘﻐﻴﺮات‬ ‫اﻟﻤﺴﺘﺨﺪﻣﺔ‪ ‬‬ ‫‪Display Variables with‬‬ ‫‪Information‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪ ‬‬ ‫‪ ‬‬ ‫‪ ‬‬ ‫‪ ‬‬

‫إﺟﺮا ‪ ‬ﺑﻌﺾ‪ ‬اﻟﻌﻤﻠﻴﺎت‪ ‬اﻟﺮﻳﺎﺿﻴﺔ اﻟﺒﺴﻴﻄﺔ‬ ‫>>‬ ‫‪>>a*b‬‬ ‫‪a*b‬‬ ‫ﻋﻠﻰ‪ ‬اﻟﻤﺘﻐﻴﺮﻳﻦ‪  ‬اﻟﻤﺮﺁﺒﻴﻦ‪  ‬وﻩﻲ‪ ‬ﺑﺎﻟﺘﺮﺗﻴﺐ‪ ‬‬ ‫>>‬ ‫‪>>a/b‬‬ ‫‪a/b‬‬ ‫اﻟﺠﻤﻊ‪ ‬ﺛﻢ‪ ‬اﻟﻀﺮب‪ ‬ﺛﻢ‪ ‬اﻟﻘﺴﻤﺔ‪ ‬ﺛﻢ‪ ‬اﻟﻄﺮح ‪ ‬‬

‫‪Some math operations‬‬

‫أواﻣﺮ‪ ‬إﺿﺎﻓﻴﺔ‬ ‫ﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‬

‫ﻹﻧﺸﺎ ‪ ‬اﻟﻤﺘﻐﻴﺮﻳ )‪ (a‬وﻳﺴﺎوي )‪(2‬‬ ‫واﻟﻤﺘﻐﻴﺮ‪ ( b) ‬ﻳﺴﺎوي )‪  (10‬‬ ‫ﻻﺣﻆ‪ ‬أن‪ ‬اﻟﻤﺘﻐﻴﺮ )‪ (a‬ﻻ‪ ‬ﻳﺴﺎوي‪ ‬اﻟﻤﺘﻐﻴﺮ‬ ‫)‪ (A‬ن‪ ‬اﻟﻤﺎﺗﻼب ‪ Case Sensitive‬‬

‫ﻹﻧﺸﺎ ‪ ‬ﺛﻼث‪ ‬ﻣﺘﻐﻴﺮات‪ ‬ﻣﻊ‪ ‬ﻋﺪم‪  ‬إﻇﻬﺎرﻩﻢ‬ ‫>>‬ ‫;‪>>B=2‬‬ ‫;‪B=2‬‬ ‫ﻋﻠ ‪ ‬اﻟﺸﺎﺷﺔ‪ ‬ﺑﺎﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ );( ‪ ‬‬

‫اﻟﻌﺪد‪ ‬اﻟﺘﺨﻴﻠﻲ ‪i‬‬ ‫‪The complex number i‬‬

‫اﻷﻋﺪاد‪  ‬اﻟﻤﺮﺁﺒﺔ‪ ‬‬ ‫‪Complex‬‬ ‫‪ Numbers‬‬ ‫‪ ‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬

‫اﻟﺤﺼﻮل‪ ‬ﻋﻠﻰ‪ ‬اﻟﺠﺰ ‪ ‬اﻟﺤﻘﻴﻘﻲ‪ ‬ﻓﻘﻂ‬ ‫>>‬ ‫)‪>>real(z‬‬ ‫‪real(z) ‬‬ ‫ﻟﻠﻤﺘﻐﻴﺮ‪  ‬اﻟﻤﺮﺁﺐ‪  (z) ‬‬ ‫‪ >>imag(z) ‬اﻟﺤﺼﻮل‪ ‬ﻋﻠﻰ‪ ‬اﻟﺠﺰ ‪ ‬اﻟﺘﺨﻴﻠﻲ‪ ‬ﻓﻘﻂ‬ ‫ﻟﻠﻤﺘﻐﻴﺮ‪  ‬اﻟﻤﺮﺁﺐ‪  (z) ‬‬ ‫‪ >>angle(z) ‬اﻟﺤﺼﻮل‪ ‬ﻋﻠﻰ‪ ‬زاوﻳﺔ‪ ‬اﻟﻄﻮر‪ ‬ﻟﻠﻤﺘﻐﻴﺮ‬ ‫اﻟﻤﺮﺁﺐ‪ (z) ‬ﺑﺎﻟﺮادﻳﺎ ‪ ‬‬ ‫‪ >>abs(z) ‬اﻟﺤﺼﻮل‪ ‬ﻋﻠﻰ‪ ‬اﻟﻘﻴﻤﺔ‪ ‬اﻟﻤﻄﻠﻘﺔ‪ ‬ﻟﻠﻤﺘﻐﻴﺮ‬ ‫اﻟﻤﺮﺁﺐ‪(z) ‬‬ ‫‪ >>who ‬ﻋﺮض‪  ‬ﺁﺎﻓﺔ‪ ‬اﻟﻤﺘﻐﻴﺮات‪ ‬اﻟﻤﺴﺘﺨﺪﻣﺔ‪ ‬ﻓﻲ‬ ‫ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ‪ ‬‬ ‫ﻋﺮض‪ ‬ﻣﻔﺼﻞ‪ ‬ﻟﻜﺎﻓﺔ‪ ‬اﻟﻤﺘﻐﻴﺮات‬ ‫اﻟﻤﺴﺘﺨﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ‪ ‬ﻣﻊ‪ ‬ﻋﺮض‪ ‬‬ ‫‪>>whos ‬‬ ‫اﻟﺤﺠﻢ‪ ‬وﻣﻘﺪار‪  ‬اﻟﺬاﺁﺮة‪ ‬اﻟﻤﺤﺠﻮزة‪ ‬ﺑﺎﻟﺒﺎﻳﺖ‪ ‬‬ ‫وﻧﻮع‪ ‬اﻟﻤﺘﻐﻴ ‪ ‬‬

‫‪6‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ‪ ‬اﻟﺨﺎﻣ )اﻟ ﺘﺠﻬﺎ (‪ ‬‬ ‫)‪Matlab Examples in Chapter 5 (Vectors‬‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬

‫اﻟﻤﻮﺿﻮع اﻟﺮﺋﻴﺴ ‪ ‬‬

‫اﻟﻤﺘﺠﻪ‪ ‬اﻟﺼﻔﻲ‪ ‬‬ ‫‪Row‬‬ ‫‪Vector‬‬

‫ﻃﺮﻳﻘﺔ أﺧﺮى‪ ‬ﻹﻧﺸﺎ ‪ ‬اﻟﻤﺘﺠﻪ‪ ‬اﻟﺼﻔ‬ ‫‪Second Method‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﺻﻔﻲ‪ ‬‬ ‫‪Row Vector‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬‬

‫‪Vector Definition ‬‬

‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬

‫>> إﻧﺸﺎ ﺘﺠﻪ‪ ‬ﺻﻔﻲ‪ ‬ﻣﻦ‪ ‬ﺧﻤﺴﺔ‪ ‬‬ ‫‪ ‬‬ ‫‪ A=[1‬‬ ‫‪A=[1 2 3 4 5] ‬‬ ‫ﺻﻋﺮﻨﺎ‪ ‬ﺻﺮ‬ ‫ﺑﻄﺮﻳﻘﺔ‪ ‬اﻟﻔﺮاﻏﺎت‪ ‬ﺑﻴﻦ‪ ‬ا ﻌﻨﺎ‬ ‫إﻧﺸﺎ‪  ‬ﻧﻔﺲ‪ ‬اﻟﻤﺘﺠﻪ‪ ‬اﻟﺴﺎﺑﻖ‪ ‬ﺑﺎﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ‬ ‫>> )‪ (:‬واﻟﺬي‪ ‬ﻳﻌﻨﻲ‪  ‬ﺁﺎﻓﺔ‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬ﻣﻦ )‪ (1‬إﻟﻰ‬ ‫‪ ‬‬ ‫‪ A=[1‬‬ ‫‪A=[1:5] ‬‬ ‫)‪ (5‬ﺑﺰﻳﺎدة‪ ‬واﺣﺪ‪ ‬ﻋﻦ‪ ‬اﻟﺴﺎﺑ ‪ ‬‬

‫‪ >>D=[2‬إﻧﺸﺎ‬ ‫‪>>D=[2 4 6 8 10]  ‬‬

‫اﻟﻄﺮﻳﻘﺔ أﺧﺮى‪ ‬ﻹﻧﺸﺎ ‪ ‬اﻟﻤﺘﺠﻪ‪ ‬اﻟﺼﻔ‬

‫]‪>>D=[2:2:10‬‬ ‫‪>>D=[2:2:10] ‬‬

‫‪Second Method‬‬

‫اﻟﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‬ ‫اﻟﻤﺘﺠﻬﺎ ‪ ‬‬ ‫‪Operations on‬‬ ‫‪Vectors‬‬

‫اﻟﻤﺘﺠﻪ‪ ‬اﻟﻌﻤﻮدي‪ ‬‬ ‫‪Column Vector‬‬

‫]‪>>C=[1;2;3;4;5‬‬ ‫‪>>C=[1;2;3;4;5]  ‬‬

‫إﺿﺎﻓﺔ‪ ‬ﻋﻨﺼﺮ‪ ‬ﺟﺪﻳﺪ‪ ‬ﻟﻠﻤﺘﺠﻪ‪ ‬‬ ‫‪Element Adding‬‬

‫>>‬ ‫‪ ‬‬ ‫]‪ A=[1;3;5;7;8‬‬ ‫]‪A=[1;3;5;7;8‬‬ ‫>>‬ ‫‪ ‬‬ ‫‪ A(6)=100‬‬ ‫‪A(6)=100 ‬‬

‫إﺿﺎﻓﺔ‪ ‬ﻋﻨﺼﺮ‪ ‬ﺟﺪﻳﺪ‪ ‬ﻟﻠﻤﺘﺠﻪ‪ ‬‬ ‫‪Element Adding‬‬

‫>>‬ ‫‪ ‬‬ ‫‪ A(8)=150‬‬ ‫‪A(8)=150 ‬‬

‫ﺣﺬف‪ ‬ﻋﻨﺼﺮ‪ ‬ﻣﻦ‪ ‬ﻣﺘﺠﻪ‪ ‬‬ ‫‪Element Deletion‬‬ ‫اﺳﺘﺒﺪال‪ ‬ﻗﻴﻤﺔ‪ ‬ﻋﻨﺼﺮ‪ ‬ﻓﻲ‪ ‬ﻣﺘﺠﻪ‪ ‬‬ ‫‪Element Replacing‬‬ ‫ﻗﻴﻤﺔ‪ ‬اﻟﻌﻨﺼﺮ‪  ‬اﻷﺁﺒﺮ ﻟﻤﺘﺠ ‪ ‬‬ ‫‪Maximum Value‬‬ ‫ﻗﻴﻤﺔ‪ ‬اﻟﻌﻨﺼﺮ‪ ‬اﻷﺻﻐﺮ‪ ‬ﻟﻤﺘﺠﻪ‪ ‬‬ ‫‪Minimum Value‬‬ ‫ﻃﻮل‪ ‬اﻟﻤﺘﺠﻪ‪ ‬‬ ‫‪Vector Length‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬

‫]‪>>B=[1;3;5;7;9‬‬ ‫]‪>>B=[1;3;5;7;9‬‬ ‫][=)‪>>B(5‬‬ ‫‪>>B(5)=[] ‬‬ ‫]‪>>B=[1;3;5;7;9‬‬ ‫]‪>>B=[1;3;5;7;9‬‬ ‫‪>>B(3)=20‬‬ ‫‪>>B(3)=20 ‬‬ ‫]‪>>A=[7;8;3;4;5‬‬ ‫)‪>>max(A‬‬ ‫‪>>max(A) ‬‬ ‫)‪>>min(A‬‬ ‫‪>>min(A) ‬‬

‫ﺘﺠﻪ‪ ‬ﺻﻔﻲ‪ ‬ﻣﻦ‪ ‬ﺧﻤﺴﺔ‪ ‬ﻋﻨﺎﺻﺮ ‪ ‬‬

‫إﻧﺸﺎ ﻧﻔﺲ‪  ‬ﻟﻤﺘﺠﻪ‪ ‬اﻟﺴﺎﺑﻖ‪ ‬ﺑﺎﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ‬ ‫)‪ (:‬واﻟﺬي‪ ‬ﻳﻌﻨﻲ‪  ‬ﺁﺎﻓﺔ‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬ﻣﻦ )‪ (2‬إﻟﻰ‬ ‫)‪ (10‬ﺑﺰﻳﺎدة )‪ (2‬ﻋﻦ‪ ‬اﻟﺴﺎﺑﻖ‪   ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﻋﻤﻮدي‪ ‬ﻣﻦ‪ ‬ﺧﻤﺴﺔ‪ ‬ﻋﻨﺎﺻﺮ‬ ‫ﺑﺎﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ‪ (;) ‬واﻟﺬي‪ ‬ﻳﻌﻨﻲ‪ ‬ﻧﻬﺎﻳﺔ‬ ‫اﻟﺼﻒ‪ ‬ﻓﻲ‪ ‬اﻟﻤﺘﻐﻴﺮ‪  (C) ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﻋﻤﻮدي )‪ (A‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬إﺿﺎﻓﺔ‬ ‫ﻋﻨﺼﺮ‪ ‬ﺳﺎدس‪ ‬ﺑﻘﻴﻤﺔ‪  (100) ‬‬ ‫إﺿﺎﻓﺔ‪ ‬ﻋﻨﺼﺮ‪ ‬ﺛﺎﻣﻦ ﻟﻠﻤﺘﺠﻪ )‪ (A‬ﺑﻘﻴﻤﺔ‬ ‫)‪ (150‬وﻳﻼﺣﻆ ﻌﺪ‪ ‬اﻟﺘﻨﻔﻴﺬ أن‪ ‬اﻟﻤﺎﺗﻼب‬ ‫أﺿﺎف‪ ‬ﺁﻟﻴﺎ‪ ‬اﻟﻘﻴﻤﺔ‪ ‬ﺻﻔﺮ‪ ‬ﻟﻠﻌﻨﺼﺮ‪ ‬اﻟﺴﺎﺑﻊ‪  ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﻋﻤﻮدي )‪ (B‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬ﺣﺬف‬ ‫اﻟﻌﻨﺼﺮ‪ ‬اﻟﺨﺎﻣﺲ‪ ‬ﻓﻘﻂ‪  ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﻋﻤﻮدي )‪ (B‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬ﺗﻐﻴﻴﺮ‬ ‫ﻗﻴﻤﺔ‪ ‬اﻟﻌﻨﺼﺮ‪ ‬اﻟﺜﺎﻟﺚ‪ ‬إﻟﻰ‪ ‬اﻟﻘﻴﻤﺔ‪  (20) ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﻋﻤﻮدي )‪ (A‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬إﻳﺠﺎد‬ ‫ﻗﻴﻤﺔ‪ ‬اﻟﻌﻨﺼﺮ‪  ‬اﻷﺁﺒﺮ‪ ‬ﻓﻴﻪ‪ ‬‬ ‫ﻳﺠﺎد‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﻌﻨﺼﺮ‪ ‬اﻷﺻﻐﺮ‪ ‬ﻟﻠﻤﺘﺠﻪ )‪ (A‬‬

‫]‪ >>A=[1 7 9 8 6‬إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﺻﻔﻲ )‪ (A‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬إﻳﺠﺎد‬ ‫‪ >>length(A)  ‬ﻃﻮﻟﻪ‪ ‬وﻳﺴﺎوي‪ ‬ﻋﺪد‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬ﻓﻴﻪ‪  ‬‬ ‫]‪>>x=[1 2 3‬‬

‫)‪ >>norm(x,1‬إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﺻﻔﻲ )‪ (x‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬إﻳﺠﺎد‬ ‫)‪ >>norm(x‬ﻣﻘﺎﻳﻴﺴﻪ‪ ‬اﻷول‪ ‬واﻟﺜﺎﻧﻲ )ﺑﻄﺮﻳﻘﺘﻴ ( وأﺧﻴﺮا‬ ‫)‪ >>norm(x,2‬اﻟﻤﻘﻴﺎس‪ ‬اﻟﻼﻧﻬﺎﺋﻲ‪ ‬‬

‫ﻣﻘﻴﺎس اﻟﻤﺘﺠﻪ‬

‫‪ ‬‬ ‫‪  Norm‬‬ ‫‪Vector‬‬ ‫ﻣﺜﺎل‪ ‬ﺁﺧﺮ‪ ‬ﻟﻤﻘﻴﺎس‪ ‬اﻟﻤﺘﺠﻪ‪ ‬‬ ‫‪Vector Norm‬‬

‫ﺿﺮب‪ ‬اﻟﻤﺘﺠﻬﺎت‪ ‬‬ ‫‪Vector Product‬‬

‫اﻟﻀﺮب‪ ‬اﻟﻤﺘﺠﻪ‪ ‬‬ ‫‪Dot Product‬‬ ‫اﻟﻀﺮب‪ ‬اﻟﻤﺘﺠ ‪ ‬‬ ‫‪Cross Product‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪>>norm(x,inf)  ‬‬ ‫]‪>>a=[-10 -5 3‬‬ ‫)‪>>norm(x,1‬‬ ‫‪>>norm(x,inf)  ‬‬ ‫]‪>>A=[1 2 3‬‬ ‫]‪>>B=[4 5 6‬‬ ‫‪>>dot(A,B) ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‪ ‬ﺻﻔﻲ )‪ (a‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬إﻳﺠﺎد‬ ‫ﻣﻘﺎﻳﻴﺴﻪ‪ ‬اﻷول‪ ‬واﻟﻼﻧﻬﺎﺋﻲ ‪  ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻬﻴﻦ‪ ‬ﺻﻔﻴﻴﻦ )‪ (A‬و )‪ (B‬وﻣﻦ‪ ‬ﺛﻢ‬ ‫إﻳﺠﺎد‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﻀﺮب‪ (dot) ‬ﺑﻴﻨﻬﻤ ‪ ‬‬ ‫إﻳﺠﺎد‪ ‬ﻗﻴﻤﺔ‪ ‬اﻟﻀﺮب‪ ‬ﻣﻦ‪ ‬ﻧﻮع )‪(cross‬‬ ‫‪>>cross(A,B)  ‬‬ ‫ﻟﻠ ﺘﺠﻬﻴﻦ )‪ (A‬و )‪ (B‬‬

‫‪7‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ‪ ‬ا‪‬ﻟ‪‬ﺴ‪‬ﺎ‪‬د‪‬س )اﻟﻤﺼﻔﻮﻓﺎ (‪ ‬‬ ‫)‪Matlab Examples in Chapter 6 (Matrices‬‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺼﻔﻮﻓﺔ‪ ‬‬

‫‪Matrix Definition ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬

‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬

‫اﻟﻄﺮﻳﻘﺔ‪ ‬اﻷوﻟﻰ‪ ‬‬ ‫‪First Method‬‬

‫>>‬ ‫‪ ‬‬ ‫‪ A=[1‬‬ ‫;‪A=[1 2‬‬ ‫‪2;4‬‬ ‫‪4 5;7 6] ‬‬

‫اﻟﻄﺮﻳﻘﺔ‪ ‬اﻟﺜﺎﻧﻴﺔ‬ ‫‪Second Method‬‬

‫>>‬ ‫‪ ‬‬ ‫]‪ A=[1,2;4,5;7,6‬‬ ‫‪A=[1,2;4,5;7,6] ‬‬

‫اﻟﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﺼﻔﺮﻳﺔ‪ ‬اﻟﻤﺮﺑﻌﺔ‬

‫‪>>o=zeros(3)  ‬‬

‫‪ Square Zeros Matrix‬‬

‫اﻟﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﺼﻔﺮﻳﺔ‪ ‬اﻟﻤﺴﺘﻄﻴﻠﺔ‬

‫اﻟﻤﺼﻔﻮﻓﺎت‪ ‬اﻟﺨﺎﺻﺔ‬ ‫‪Special‬‬ ‫‪ Matrices‬‬

‫‪ Rectangular Zeros Matrix‬‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬اﻟﻮاﺣﺪ‪ ‬اﻟﻤﺮﺑﻌﺔ‬ ‫‪ Square Ones Matrix‬‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬اﻟﻮاﺣﺪ‪ ‬اﻟﻤﺴﺘﻄﻴﻠﺔ‬ ‫‪ Rectangular Ones Matrix‬‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬اﻟﻮﺣﺪة‪ ‬اﻟﻤﺮﺑﻌﺔ ‪ ‬‬ ‫‪Square Identity Matrix‬‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬اﻟﻮﺣﺪة‪ ‬اﻟﻤﺴﺘﻄﻴﻠ ‪ ‬‬ ‫‪Rectangular 1’s Diagonal‬‬ ‫‪Matrix‬‬ ‫اﻟﻤﺼﻔﻮﻓﺔ‪ ‬ا ﻌﺸﻮاﺋﻴ ‪ ‬اﻟﻤﺮﺑﻌﺔ‬ ‫‪Square Random Matrix‬‬ ‫اﻟﻤﺼﻔﻮﻓﺔ‪ ‬ا ﻌﺸﻮاﺋﻴ ‪ ‬اﻟﻤﺴﺘﻄ ﻠ ‪ ‬‬ ‫‪Rectangular Random‬‬ ‫‪Matrix‬‬

‫ﺗﻌﺮﻳﻒ ﻣﺼﻔﻮﻓﺔ ﺁﻤﺜﺎ‬

‫اﻟﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬واﺣﺪة‪ ‬‬ ‫‪Operations on a‬‬ ‫‪Single Matrix‬‬

‫ﻗﻠﺐ‪ ‬اﻷﻋﻤﺪة‪  ‬ﺁﺼﻔﻮف‪ ‬‬ ‫‪Matrix Transpose‬‬ ‫ﺟﻤﻊ‪ ‬أﻋﻤﺪة‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Sum‬‬ ‫اﺳﺘﺨﻼص‪ ‬ﻋﻨﺎﺻﺮ‪ ‬ﻗﻄﺮ‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Diagonal Elements‬‬ ‫ﺟﻤﻊ‪ ‬ﻋﻨﺎﺻﺮ‪ ‬ﻗﻄﺮ‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬‬ ‫‪Sum Matrix Diagonal‬‬ ‫‪Elements‬‬ ‫أﻳﺠﺎد‪ ‬ﻣﻌﻜﻮس‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬اﻟﻤﺮﺑﻌ‬ ‫‪Square Matrix Inversion‬‬ ‫أﻳﺠﺎد‪ ‬درﺟﺔ‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Rank ‬‬ ‫أﻳﺠﺎد‪ ‬ﻣﺤﺪد‪ ‬اﻟﻤﺼﻔﻮﻓ ‪ ‬اﻟﻤﺮﺑﻌ‬ ‫‪Square Matrix Determinate‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪>>B=zeros(3,2)  ‬‬ ‫‪>>A=ones(3)  ‬‬ ‫‪>>I=ones(4,2)  ‬‬ ‫‪>>I=eye(2) ‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ )‪ (A‬ﺑﺤ ‪ 2‬‬ ‫ﺻ‪ ‬ﻓﺮﻲ‬ ‫ﺻﻒ‬ ‫ت‪ ‬ﺠﺑﻢﻴﻦ‪ ‬ﻋﻨﺎ‬ ‫‪ 3‬أﻋﻤﺪة‪ ‬ﺑﻄﺮﻳﻘﺔ‪ ‬اﻟﻔﺮاﻏﺎ‬ ‫اﻟﺼﻒ‪ ‬اﻟﻮاﺣﺪ ‪ ‬‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ )‪ (A‬ﺑﺤﺠﻢ ‪ 2‬ﺻﻒ‪ ‬ﻓﻲ‬ ‫‪ 3‬أﻋﻤﺪة‪ ‬ﺑﻄﺮﻳﻘﺔ‪ ‬اﻟﻔﻮا ‪ ‬ﺑﻴﻦ‪ ‬ﻋﻨﺎﺻﺮ‬ ‫اﻟﺼﻒ‪ ‬اﻟﻮاﺣﺪ ‪ ‬‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻤﺮﺑﻌﺔ )‪ (o‬ذات‬ ‫ﻋﻨﺎﺻﺮ ا ﺻﻔﺎر ﺑﺤﺠﻢ ‪  3×3‬‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻤﺴﺘﻄﻴﻠﺔ )‪ (B‬ذات‬ ‫اﻷﺻﻔﺎر‪ ‬ﺑﺤﺠﻢ ‪ 3‬ﺻﻒ‪ ‬ﻓﻲ ‪ 2‬أﻋﻤﺪة‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻤﺮﺑﻌﺔ )‪ (A‬ذات‬ ‫اﻟﻌﻨﺎﺻﺮ‪ ‬واﺣ ﺑﺤﺠﻢ ‪  3×3‬‬ ‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻤﺴﺘﻄﻴﻠﺔ )‪ (I‬ذات‬ ‫اﻟﻌﻨﺎﺻﺮ‪ ‬واﺣﺪ‪ ‬ﺑﺤﺠﻢ ‪ 4‬ﺻﻒ‪ ‬ﻓﻲ ‪ 2‬أﻋﻤﺪة‬ ‫ﻹﻧﺸﺎ ‪ ‬ﻣﺼﻔﻮﻓﺔ ا ﻮﺣﺪة ا ﻤﺮﺑﻌ )‪ (I‬ﺑﺤﺠﻢ‬ ‫‪  2×2‬‬

‫‪>>Y=eye(3,4)  ‬‬

‫ﻹﻧﺸﺎ ‪ ‬ﻣﺼﻔﻮﻓﺔ ا ﻮﺣﺪة اﻟﻤﺴﺘﻄﻴﻠﺔ )‪(Y‬‬ ‫ﺑﺤﺠﻢ‪ 3 ‬ﺻﻒ‪ ‬ﻓﻲ ‪ 4‬أﻋﻤﺪ‬

‫‪>>I=rand(5)  ‬‬

‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻌﺸﻮاﺋﻴﺔ ا ﻤﺮﺑﻌ )‪(I‬‬ ‫ﺑﺤﺠﻢ‪  5×5 ‬‬

‫‪>>I=rand(3,2)  ‬‬

‫ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ ا ﻌﺸﻮاﺋﻴﺔ اﻟﻤﺴﺘﻄﻴﻠﺔ )‪(I‬‬ ‫ﺑﺤﺠﻢ‪ 3 ‬ﺻﻒ‪ ‬ﻓﻲ ‪ 2‬أﻋﻤﺪ‬

‫‪ >>B=[1‬ﻹﻧﺸﺎ ا ﻤﺼﻔﻮﻓﺔ )‪ (B‬ﺑﺤﺠﻢ ‪ 3‬ﺻﻒ‪ ‬ﻓﻲ‬ ‫‪>>B=[1 -5 3;6 10‬‬ ‫‪ 3 -9; 11 8 4] ‬أﻋﻤﺪة‬ ‫ﻗﻠﺐ‪ ‬اﻷﻋﻤﺪة‪  ‬ﺁﺼﻔﻮف‪ ‬واﻟﺼﻔﻮف‪  ‬ﺁﺄﻋﻤﺪ‬ ‫’‪>>B‬‬ ‫‪>>B’ ‬‬ ‫ﻟﻠﻤﺼﻔﻮﻓﺔ‪  (B) ‬‬ ‫)‪>>sum(B‬‬ ‫(‪>>sum‬‬ ‫‪B) ‬‬ ‫)‪>>diag(B‬‬ ‫(‪>>diag‬‬ ‫‪B) ‬‬ ‫))‪>>sum(diag(B‬‬ ‫(‪>>sum(diag‬‬ ‫‪B)) ‬‬ ‫)‪>>inv(B‬‬ ‫(‪>>inv‬‬ ‫‪B) ‬‬ ‫)‪>>rank(B‬‬ ‫(‪>>rank‬‬ ‫‪B) ‬‬ ‫)‪>>det(B‬‬ ‫(‪>>det‬‬ ‫‪B) ‬‬

‫‪8‬‬

‫ﺟﻤﻊ‪ ‬أﻋﻤﺪة‪ ‬اﻟﻤﺼﻔﻮﻓ )‪(B‬‬ ‫اﺳﺘﺨﻼص‪ ‬ﻋﻨﺎﺻﺮ‪ ‬ﻗﻄﺮ اﻟﻤﺼﻔﻮﻓ )‪ (B‬‬ ‫ﺟﻤﻊ‪ ‬ﻋﻨﺎﺻﺮ‪ ‬ﻗﻄﺮ اﻟﻤﺼﻔﻮﻓ )‪ (B‬‬ ‫إﻳﺠﺎد‪ ‬اﻟﻤﻌﻜﻮس‪ ‬ﻟﻠﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﻤﺮﺑﻌﺔ )‪  (B‬‬ ‫إﻳﺠﺎد‪ ‬درﺟﺔ‪ ‬اﻟﻤﺼﻔﻮﻓ )‪ (B‬‬ ‫إﻳﺠﺎد‪ ‬اﻟﻤﺤﺪد‪ ‬ﻟﻠﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﻤﺮﺑﻌﺔ )‪ (B‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﺗﺎﺑﻊ ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ‪ ‬اﻟﺴﺎدس )اﻟﻤﺼﻔﻮﻓﺎ‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬

‫ﺗﺎﺑﻊ‪ ‬اﻟﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‬ ‫ﻣﺼﻔﻮﻓﺔ‪ ‬واﺣﺪة‪ ‬‬ ‫‪Operations on a‬‬ ‫‪ Single Matrix‬‬

‫‪ ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬ ‫أﻳﺠﺎد‪ ‬اﻟﻘﻴﻢ‪ ‬اﻟﺬاﺗﻴﺔ‪ ‬ﻟﻤﺼﻔﻮﻓ ‪ ‬ﻣﺮﺑﻌ‬ ‫‪Eigenvalues of Square‬‬ ‫‪Matrix‬‬ ‫أﻳﺠﺎد‪ ‬اﻟﻘﻴﻢ‪ ‬واﻟﻤﺘﺠﻬﺎت‪ ‬اﻟﺬاﺗﻴﺔ‬ ‫ﻟﻤﺼﻔﻮﻓ ‪ ‬ﻣﺮﺑﻌ‬ ‫‪Eigenvalues and‬‬ ‫‪Eigenvectors‬‬ ‫اﺧﺘﻴﺎر‪ ‬ﺻﻒ‪ ‬ﻣﺤﺪد‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Row Selection‬‬ ‫اﺧﺘﻴﺎر‪ ‬ﻋﻤﻮد‪ ‬ﻣﺤﺪد‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Column Selection‬‬ ‫اﺧﺘﻴﺎر‪ ‬اﻟﺼﻒ‪ ‬اﻷﺧﻴﺮ‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Last Row Selection‬‬ ‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻤﻮد‪ ‬اﻷﺧﻴﺮ‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Matrix Last Column‬‬ ‫‪Selection‬‬

‫)‪>>eig(B‬‬ ‫(‪>>eig‬‬ ‫‪B) ‬‬

‫)‪>>B(2,:‬‬ ‫‪>>B(2,:) ‬‬ ‫)‪>>B(:,2‬‬ ‫‪>>B(:,2) ‬‬ ‫)‪>>B(end,:‬‬ ‫‪>>B(end,:) ‬‬ ‫)‪>>B(:,end‬‬ ‫‪>>B(:,end) ‬‬

‫اﺧﺘﻴﺎر‪ ‬ﻣﺼﻔﻮﻓﺔ‪ ‬ﺟﺰﺋﻴﺔ‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Submatrix Selection‬‬

‫)‪>>B(1:2,1:2‬‬ ‫‪>>B(1:2,1:2) ‬‬

‫اﺧﺘﻴﺎر‪ ‬ﻣﺼﻔﻮﻓﺔ‪ ‬ﺟﺰﺋﻴﺔ‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Submatrix Selection‬‬

‫)‪>>B(3,2:3‬‬ ‫‪>>B(3,2:3) ‬‬

‫اﻟﻌﻤﻠﻴﺎت‪ ‬ﻋﻠﻰ‪  ‬أﺁﺜﺮ‬ ‫ﻣﻦ‪ ‬ﻣﺼﻔﻮﻓﺔ‪ ‬واﺣﺪ‬

‫ﺣﻞ‪ ‬ﻣﻨﻈﻮﻣﺔ‪ ‬ﻣﻌﺎدﻻت‬ ‫ﺧﻄﻴﺔ‬

‫إﻧﺸﺎ ‪ ‬اﻟﻤﻌﺎدﻻت‪ ‬وﺣﻠﻬﺎ‪ ‬‬ ‫‪Building and Solving the‬‬ ‫‪System‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬ ‫إﻳﺠﺎد‪ ‬اﻟﻘﻴﻢ‪ ‬اﻟﺬاﺗﻴﺔ‪ ‬ﻟﻠﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﻤﺮﺑﻌﺔ )‪ (B‬‬

‫إﻳﺠﺎد‪ ‬اﻟﻘﻴﻢ‪ ‬اﻟﺬاﺗﻴ )‪ (V‬واﻟﻤﺘﺠﻬﺎت‪ ‬اﻟﺬاﺗﻴ‬ ‫)‪>>[V,D] = eig(B‬‬ ‫‪eig(B) ‬‬ ‫)‪ (D‬ﻟﻠﻤﺼﻔﻮﻓﺔ‪ ‬اﻟﻤﺮﺑﻌﺔ )‪ (B‬‬

‫اﺧﺘﻴﺎر‪ ‬ﻣﺼﻔﻮﻓﺔ‪ ‬ﺟﺰﺋﻴﺔ‪ ‬ﻣﻦ ﻣﺼﻔﻮﻓ ‪ ‬‬ ‫‪Submatrix Selection‬‬

‫ﺟﻤﻊ ﻣﺼﻔﻮ ﺘﻴ ‪ ‬‬ ‫‪Matrix Addition‬‬ ‫ﻃﺮح ﻣﺼﻔﻮ ﺘﻴ ‪ ‬‬ ‫‪Matrix Subtraction‬‬ ‫ﺿﺮب ﻣﺼﻔﻮ ﺘﻴ ‪ ‬‬ ‫‪Matrix Multiplicat‬‬ ‫‪Multiplication‬‬ ‫‪ion‬‬ ‫ﻗﺴﻤﺔ ﻣﺼﻔﻮ ﺔ‪ ‬ﻋﻠﻰ‪ ‬ﻋﺪ ‪ ‬‬ ‫‪Matrix Multiplication‬‬ ‫‪Multiplication‬‬

‫‪Solving a System‬‬ ‫‪of Linear‬‬ ‫‪Equations ‬‬

‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬

‫)‪>>B(1:2,2‬‬ ‫‪>>B(1:2,2) ‬‬

‫ﺗﻌﺮﻳﻒ‪ ‬ﻣﺠﻤﻮﻋﺔ ﻣﺼﻔﻮ ﺎ‬

‫‪Operations on‬‬ ‫‪Matrices‬‬

‫(‬

‫>>‬ ‫‪ ‬‬ ‫‪ A=[3‬‬ ‫;]‪A=[3 4 6;5 1 8‬‬ ‫‪>>B=[7‬‬ ‫;]‪>>B=[7 9 4;8 1 1‬‬ ‫;]‪>>C=[1;3;4‬‬ ‫‪>>C=[1;3;4]; ‬‬

‫اﺧﺘﻴﺎر‪ ‬اﻟﺼﻒ‪ ‬اﻟﺜﺎﻧﻲ‪ ‬ﻓﻘﻂ‪ ‬ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓ‬ ‫)‪ (B‬‬

‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻤﻮد‪ ‬اﻟﺜ ﻧﻲ‪ ‬ﻓﻘﻂ‪ ‬ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓ‬

‫)‪ (B‬‬

‫اﺧﺘﻴﺎر‪ ‬اﻟﺼﻒ‪ ‬اﻷﺧﻴﺮ‪ ‬ﻓﻘﻂ‪ ‬ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓ‬

‫)‪ (B‬‬

‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻤﻮد‪ ‬اﻷﺧﻴﺮ‪ ‬ﻓﻘﻂ‪ ‬ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓ‬ ‫)‪ (B‬‬

‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬اﻟﻤﺘﻘﺎﻃﻌﺔ‪ ‬ﻣﺎ‪ ‬ﺑﻴﻦ‪ ‬اﻟﺼﻔﻴﻦ‬ ‫اﻷول‪ ‬واﻟﺜﺎﻧﻲ‪ ‬ﻣﻊ‪ ‬ﻋﻨﺎﺻﺮ‪ ‬اﻟﻌﻤﻮد‪ ‬اﻟﺜﺎﻧﻲ‬ ‫ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓﺔ )‪ (B‬‬ ‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬اﻟﻤﺘﻘﺎﻃﻌﺔ‪ ‬ﻣﺎ ﺑﻴﻦ‪ ‬اﻟﺼﻔﻴﻦ‬ ‫ل‬ ‫اﻷول‪ ‬واﻟﺜﺎﻧﻲ‪ ‬ﻣﻊ‪ ‬ﻋﻨﺎﺻﺮ‪ ‬اﻟﻌﻤﻮدﻳﻦ‪ ‬اﻷو ‪ ‬‬ ‫واﻟﺜﺎﻧﻲ ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓ )‪ (B‬‬ ‫اﺧﺘﻴﺎر‪ ‬اﻟﻌﻨﺎﺻﺮ‪ ‬اﻟﻤﺘﻘﺎﻃﻌﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺼﻒ‬ ‫اﻟﺜﺎﻟﺚ‪ ‬ﻣﻊ‪ ‬ﻋﻨﺎﺻﺮ‪ ‬اﻟﻌﻤﻮدﻳﻦ‪ ‬اﻟﺜﺎﻧﻲ‪ ‬واﻟﺜﺎﻟﺚ‬ ‫ﻣﻦ‪ ‬اﻟﻤﺼﻔﻮﻓﺔ )‪ (B‬‬ ‫إﻧﺸﺎ ﺛﻼث ﻣﺼﻔﻮﻓﺎت‪ ‬ﻟﻐﺮض‪ ‬ﺗﻄﺒﻴﻖ‬ ‫اﻷﻣﺜﻠﺔ‪ ‬اﻟﺘﺎﻟﻴﺔ‪  ‬‬

‫‪>>A+B‬‬ ‫‪>>A+‬‬ ‫‪B ‬‬

‫ﻋﻤﻠﻴﺔ‪ ‬ﺟﻤﻊ ا ﻤﺼﻔﻮﻓﺘﻴ )‪ (A‬و )‪  (B‬‬

‫‪>>A-B‬‬ ‫‪>>A‬‬‫‪B ‬‬

‫ﻋﻤﻠﻴﺔ‪ ‬ﻃﺮح ا ﻤﺼﻔﻮﻓﺘﻴ )‪ (A‬و )‪ (B‬‬

‫‪>>A*C‬‬ ‫*‪>>A‬‬ ‫‪C ‬‬

‫ﻋﻤﻠﻴﺔ‪ ‬ﺿﺮب ا ﻤﺼﻔﻮﻓﺘﻴ )‪ (A‬و )‪ (C‬‬

‫‪>>A/3 ‬‬

‫ﻋﻤﻠﻴﺔ‪ ‬ﻗﺴﻤﺔ ا ﻤﺼﻔﻮﻓﺔ )‪ (A‬ﻋﻠﻰ‪ ‬ﻋﺪ ‪ ‬‬

‫ﻗﻢ‪ ‬ﺑﺘﻄﺒﻴﻖ‪ ‬اﻷواﻣﺮ‪ ‬اﻟﻤﻮﺿﺤﺔ‪ ‬وذﻟﻚ‪ ‬ﻟﺤﻞ‬ ‫>>‬ ‫‪ ‬‬ ‫‪ A=[1‬‬ ‫‪A=[1 -1 1;1 2‬‬ ‫ﻣﻨﻈﻮﻣﺔ‪ ‬اﻟﻤﻌﺎدﻻت‪ ‬اﻟﺨﻄﻴﺔ‪ ‬اﻟﺘﺎﻟﻴﺔ‪: ‬‬ ‫]‪2;3 0 1‬‬ ‫]‪>>b=[5;10;1‬‬ ‫]‪>>b=[5;10;1‬‬ ‫‪>>x=inv(A)*b‬‬ ‫‪>>x=inv(A)*b ‬‬

‫اﻟﺘﺄﺁﺪ‪ ‬ﻣﻦ‪ ‬اﻟﺤﻞ‬

‫>>‬ ‫‪ ‬‬ ‫‪ A*x‬‬ ‫‪A*x ‬‬

‫‪ x- y+ z=5‬‬ ‫‪ x+2 y+2 z=10‬‬ ‫‪3x+ z=1‬‬ ‫ﺎﺗﺞ‪ ‬ﻋﻤﻠﻴﺔ‪ ‬اﻟﻀﺮب )‪ (A*x‬ﻳﺠﺐ‪ ‬أن‬ ‫ﻳﺴﺎوي‪ ‬اﻟﻤﺼﻔﻮﻓﺔ )‪( b‬‬

‫‪ ‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪9‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ‪ ‬اﻟﺴﺎﺑ )اﻟﺮﺳﻢ‪ ‬ﺛﻨﺎﺋﻲ‪ ‬اﻷﺑﻌﺎ (‪ ‬‬ ‫)‪Matlab Examples in Chapter 7 (Introduction to 2D Plots‬‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺮﺳﻢ‬ ‫ﺛﻨﺎﺋﻲ‪ ‬اﻷﺑﻌﺎد‪ ‬‬ ‫‪Introduction to‬‬ ‫‪2D Plots ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‬

‫‪Defining a Vector‬‬

‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬ ‫>>‬ ‫)‪>>x=linspace(5,20,10‬‬ ‫‪x=linspace(5,20,10)  ‬‬

‫اﻟﺮﺳﻢ‪ ‬ﺛﻨﺎﺋﻲ‪ ‬اﻷﺑﻌﺎ‬

‫>>‬ ‫;)‪>>x=linspace(0,10,100‬‬ ‫;)‪x=linspace(0,10,100‬‬ ‫;)‪>>y=sin(x‬‬ ‫‪>>plot(x,y)  ‬‬

‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‬

‫>>‬ ‫;)‪>>x=linspace(0,1,100‬‬ ‫;)‪x=linspace(0,1,100‬‬ ‫;)‪>>y=exp(-x).*cos(6*pi*x‬‬ ‫‪>>plot(x,y) ‬‬

‫‪2D Plot‬‬

‫‪Defining a Vector‬‬

‫‪>>plot(x,y,’r’)  ‬‬

‫ﺗﻐﻴﻴﺮ‪ ‬ﻟﻮن‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‬ ‫‪Line Color‬‬

‫‪>>plot(x,y,’g’)  ‬‬

‫إﺿﺎﻓﺔ‪ ‬ﻋﻼﻣﺔ‪ ‬ﻟﺨﻂ‪ ‬اﻟﺮﺳﻢ‬

‫‪>>plot(x,y,’*’)  ‬‬

‫‪Line Mark‬‬ ‫ﺗﻐﻴﻴﺮ‪ ‬ﻧﻮع‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‪ ‬‬ ‫‪Line Style‬‬

‫إﺿﺎﻓﺔ‪ ‬ﺧﺼﺎﺋﺺ‬ ‫إﻟﻰ‪ ‬اﻟﺮﺳﻮﻣﺎت‪ ‬‬ ‫‪Setting 2D Plot‬‬ ‫‪Properties ‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪20‬ﻦ‬ ‫ﻰن‪ ‬ﻣ‬ ‫ﺿﺘﻤﺠﻦﻪ‪ ‬ا)ﻟﻔ‪x‬ﺘ(ﺮةو‪ ‬اﻟﻣﺬﻦي‪5‬ﻳ‪ ‬ﺘإﻟﻜﻮ‬ ‫‪ 10‬ﺸﻗﺎﻴﻢ‪ ‬ا ﻤ‬ ‫ﻹﻧ‬ ‫وﺗﻜﻮن‪ ‬اﻟﻘﻴﻢ‪ ‬ﻣﻮزﻋﺔ‪ ‬ﺑﺎﻟﺘﺴﺎوي‪  ‬‬ ‫ﻹﻧﺸﺎ ‪  ‬ا ﻤﺘﺠﻪ )‪ (x‬واﻟﺬي ﻳﺘﻜﻮن‪ ‬ﻣﻦ‬ ‫‪ 100‬ﻗﻴﻤﺔ‪ ‬ﺿﻤﻦ‪ ‬اﻟﻔﺘﺮة‪ ‬ﻣﻦ ‪ 0‬إﻟﻰ‬ ‫‪ 10‬وﺗﻜﻮن‪ ‬اﻟﻘﻴﻢ‪ ‬ﻣﻮزﻋﺔ‪ ‬ﺑﺎﻟﺘﺴﺎوي‬ ‫وﻣﻦ‪ ‬ﺛﻢ إﻧﺸﺎ ‪ ‬داﻟﺔ )‪ (sin‬وﺣﻔﻈﻬﺎ‪ ‬ﻓﻲ‬ ‫اﻟﻤﺘﻐﻴﺮ‪ (y) ‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬رﺳﻢ‪ ‬اﻟﺪاﻟ ‪ ‬‬ ‫ﻹﻧﺸﺎ ‪ ‬اﻟﻤﺘﺠﻬﻴﻦ )‪ (x‬و )‪ (y‬وﻣﻦ‪ ‬ﺛﻢ‬ ‫رﺳﻢ‪ ‬اﻟﺪاﻟﺔ‪ ‬ﺗﻤﺎﻣﺎ‪  ‬ﺁﻤﺎ‪ ‬ﻓﻲ‪ ‬اﻟﺨﻄﻮة‪ ‬‬ ‫اﻟﺴﺎﺑﻘﺔ‪ ‬‬ ‫ﺗﻐﻴﻴﺮ‪ ‬ﻟﻮن‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬اﻟﻠﻮن‬ ‫اﻷﺣﻤﺮ‪ ‬‬ ‫ﺗﻐﻴﻴﺮ‪ ‬ﻟﻮن‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬اﻟﻠﻮن‬ ‫اﻷﺧﻀﺮ‬ ‫إﺿﺎﻓﺔ‪ ‬ﻋﻼﻣﺔ‪ ‬اﻟﻨﺠﻤﺔ‪ ‬ﻟﺨﻂ‪ ‬اﻟﺮﺳﻢ ‪ ‬‬

‫‪ >>plot(x,y,’:’)  ‬ﺗﻐﻴﻴﺮ‪ ‬ﻧﻮع‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬اﻟﻨﻮع‬ ‫اﻟﻤﻨﻘﻂ‬ ‫ﺗﻐﻴﻴﺮ‪ ‬ﻟﻮن‪ ‬ﺧﻂ‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬اﻟﻠﻮن‬ ‫‪ >>plot(x,y,’g+’)  ‬اﻷﺧﻀﺮ‪ ‬ﻣﻊ‪ ‬إﺿﺎﻓﺔ‪ ‬ﻋﻼﻣﺔ‪ ‬زاﺋﺪ‪ ‬ﻟﺨﻂ‬ ‫اﻟﺮﺳﻢ‪ ‬‬ ‫‪ >>grid on ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬ﺷﺒﻜﺔ‪ ‬ﻟﻠﺮﺳﻢ‪ ‬ﻟﺘﺴﻬﻴﻞ‪ ‬ﻋﻤﻠﻴﺔ‬ ‫ﻗﺮا ‪‬ة‪ ‬اﻟﻘﻴﻢ‪ ‬ﻣﻦ‪ ‬اﻟﺮﺳﻢ‪ ‬‬

‫دﻣﺞ‪ ‬ﻣﺠﻤﻮﻋﺔ‪ ‬ﺧﺼﺎﺋﺺ‪ ‬ﻟﺨﻂ‪ ‬‬ ‫اﻟﺮﺳﻢ‪ ‬‬

‫إﺿﺎﻓﺔ‪ ‬ﺷﺒﻜﺔ‪ ‬ﻟﻠﺮﺳﻢ‬ ‫‪Adding Grid to Plot‬‬ ‫إزاﻟﺔ‪ ‬ﺷﺒﻜﺔ‪ ‬اﻟﺮﺳﻢ‬ ‫‪Removing Grid‬‬ ‫إﺿﺎﻓﺔ‪ ‬ﺗﺴﻤﻴﺔ‪ ‬ﻟﻤﺤﻮر‪ ‬اﻟﺴﻴﻨﺎت‬ ‫‪Adding Label to x-axis‬‬ ‫إﺿﺎﻓﺔ‪ ‬ﺗﺴﻤﻴﺔ‪ ‬ﻟﻤﺤﻮر‪ ‬اﻟﺼﺎدات‬ ‫‪Adding Label to y-axis‬‬ ‫إﺿﺎﻓﺔ‪ ‬ﻋﻨﻮان‪ ‬ﻟﻠﺮﺳﻢ‪ ‬‬ ‫‪Adding Title to Plot‬‬ ‫إﺿﺎﻓﺔ‪ ‬ﻧﺺ‪ ‬ﻟﻠﺮﺳ ‪ ‬‬ ‫‪Adding Text to Plot‬‬ ‫إﺿﺎﻓﺔ‪ ‬دﻟﻴﻞ‪ ‬ﻟﻤﻨﺤﻨﻴﺎت‪ ‬اﻟﺮﺳﻢ‪ ‬‬ ‫‪Adding Legend to Plot‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬

‫‪>>grid off ‬‬

‫ﻳﺘﻢ‪ ‬إزاﻟﺔ‪ ‬ﺷﺒﻜﺔ‪ ‬اﻟﺮﺳﻢ ‪ ‬‬

‫‪ >>xlabel(’x’) ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬ﺗﺴﻤﻴﺔ‪ ‬ﻟﻤﺤﻮر‪ ‬اﻟﺴﻴﻨﺎت‬ ‫ﺑﺎﻟﺮﻣﺰ‪  ‘x’ ‬‬ ‫‪ >>ylabel(’y’) ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬ﺗﺴﻤﻴﺔ‪ ‬ﻟﻤﺤﻮر‪ ‬اﻟﺼﺎدات‬ ‫ﺑﺎﻟﺮﻣﺰ‪  ‘y’ ‬‬ ‫‪ >>title(’graph’)  ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬ﻋﻨﻮان‪ ‬ﻟﻠﺮﺳﻢ‪ ‬ﺑﺎﻻﺳﻢ‬ ‫’‪  ‘graph‬‬

‫‪ >>text(0.35,0.6,’plot’)  ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬اﻟﻨﺺ ’‪ ‘plot‬ﻟﻠﺮﺳﻢ‬ ‫وذﻟﻚ‪ ‬ﻓﻲ‪ ‬اﻟﻤﻮﻗﻊ‪ ‬اﻟﻤﺤﺪد‪ ‬ﻓﻲ‪ ‬اﻷﻣﺮ‪ ‬‬ ‫‪ >>legend(‘X-Y Relation’) ‬ﻳﺘﻢ‪ ‬إﺿﺎﻓﺔ‪ ‬دﻟﻴﻞ‪ ‬ﻟﻤﻨﺤﻨﻴﺎت‪ ‬اﻟﺮﺳﻢ‬ ‫وذﻟﻚ‪ ‬ﻓﻲ‪ ‬ﻳﻤﻴﻦ‪  ‬اﻟﺮﺁﻦ‪ ‬اﻟﻌﻠﻮي‪ ‬ﻟﻠﺮﺳﻢ‪ ‬‬

‫‪10‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫ﺗﺎﺑﻊ ﻣﻠﺨﺺ ‪‬واﻣﺮ‪ ‬اﻟﻔﺼﻞ‪ ‬اﻟﺴﺎﺑﻊ )اﻟﺮﺳﻢ‪ ‬ﺛﻨﺎﺋﻲ‪ ‬اﻷﺑﻌﺎ‬ ‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﺮﺋﻴﺴﻲ‪ ‬‬

‫اﻟﻤﻮﺿﻮع‪ ‬اﻟﻔﺮﻋ ‪ ‬‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﺠﻪ‬ ‫‪Defining a Vector‬‬

‫إﻧﺸﺎ ‪ ‬رﺳﻮﻣﺎت‬ ‫ﻣﻨﻔﺼﻠﺔ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬‬ ‫واﺣﺪة‪ ‬‬ ‫‪Multiple 2D Plots‬‬ ‫‪in a Window ‬‬

‫ﺷﺮح‪ ‬اﻟﻤﺜﺎ ‪ ‬‬ ‫ﺗﻨﻔﻴﺬ‪ ‬اﻟﻤﺜﺎل‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ ‪ ‬‬ ‫إﻧﺸﺎ ا ﻤﺘﺠﻪ )‪ (x‬وذﻟﻚ‪  ‬ﺸﺮح‬ ‫>>‬ ‫;‪>>x=0:0.1:10‬‬ ‫‪x=0:0.1:10; ‬‬ ‫ا ﻣﺜ ﺔ‪ ‬اﻟﺘﺎﻟﻴ ‪ ‬‬ ‫‪>>subplot(2,2,1),‬‬ ‫‪plot(x,sin(x));  ‬‬

‫ﺗﻘﺴﻴﻢ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﺮﺳﻢ‪ ‬‬ ‫‪Subplots in Matlab‬‬

‫(‪ ‬‬

‫‪>>subplot(2,2,2),‬‬ ‫‪plot(x,sin(2*x));  ‬‬ ‫‪>>subplot(2,2,3),‬‬ ‫‪plot(x,cos(x));  ‬‬ ‫‪>>subplot(2,2,4),‬‬ ‫‪plot(x,exp(x));  ‬‬

‫)‪2‬‬ ‫ﺗﻘﺴﻴﻢ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬أر ‪ ‬‬ ‫‪sin‬ﺑ(‪ ‬ﻊﻓ ﻧﻲﻮ‪ ‬ااﻓﻟﻨﺬﺎﻓﺬة‬ ‫ﻓﻲ‪ (2 ‬ورﺳﻢ‪ ‬اﻟﺪاﻟ )‬ ‫اﻷوﻟﻰ )ﻳﺴﺎر‪ ‬اﻟﺼﻒ‪ ‬اﻷو (‪ ‬‬ ‫ﺗﻘﺴﻴﻢ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬أرﺑﻊ‪ ‬ﻧﻮاﻓﺬ‬ ‫ورﺳﻢ‪ ‬اﻟﺪاﻟﺔ‪ (sin 2x) ‬ﻓﻲ‪ ‬اﻟﻨﺎﻓﺬة‬ ‫اﻟﺜﺎﻧﻴﺔ‪) ‬ﻳﻤﻴﻦ‪ ‬اﻟﺼﻒ‪ ‬اﻷو (‪ ‬‬ ‫ﺗﻘﺴﻴﻢ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬أرﺑﻊ‪ ‬ﻧﻮاﻓﺬ‬ ‫ورﺳﻢ‪ ‬اﻟﺪاﻟﺔ‪ (cos) ‬ﻓﻲ‪ ‬اﻟﻨﺎﻓﺬة‪ ‬اﻟﺜﺎﻟﺜﺔ‬ ‫)ﻳﺴﺎر‪ ‬اﻟﺼﻒ‪ ‬اﻟﺜﺎﻧ (‪ ‬‬ ‫ﺗﻘﺴﻴﻢ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﺮﺳﻢ‪ ‬إﻟﻰ‪ ‬أرﺑﻊ‪ ‬ﻧﻮاﻓﺬ‬ ‫ورﺳﻢ‪ ‬اﻟﺪاﻟﺔ )‪ (exp‬ﻓﻲ‪ ‬اﻟﻨﺎﻓﺬة‬ ‫اﻟﺮاﺑﻌﺔ‪) ‬ﻳﻤﻴﻦ‪ ‬اﻟﺼﻒ‪ ‬اﻟﺜﺎﻧ (‪ ‬‬

‫>>‬ ‫;‪>>x=0:0.1:10‬‬ ‫‪x=0:0.1:10; ‬‬

‫;)‪ >>y=sin(x‬ﻳﺘﻢ‪ ‬دﻣﺞ‪ ‬اﻟﺮﺳﻮم‪ ‬ﺑﺎﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ‬ ‫;)‪ (hold on) >>z=cos(x‬واﻟﺬي‪  ‬ﻘﻮم‪ ‬ﺑﺘﺜﺒﻴﺖ‪ ‬ﻧﺎﻓﺬة‬

‫اﻟﻄﺮﻳﻘﺔ‪ ‬اﻷوﻟﻰ‪ ‬‬ ‫‪First Method‬‬

‫دﻣﺞ‪ ‬اﻟﺮﺳﻮم ‪ ‬‬ ‫‪Combining 2D‬‬ ‫‪Plots‬‬

‫اﻟﻄﺮﻳﻘﺔ‪ ‬اﻟﺜﺎﻧﻴﺔ‬ ‫‪Second Method‬‬

‫‪>>hold‬‬ ‫‪on‬‬ ‫;)‪>>plot(x,y‬‬ ‫;)’‪>>plot(x,z,’r‬‬ ‫‪>>hold off ‬‬ ‫>>‬ ‫;‪>>x=0:0.1:10‬‬ ‫‪x=0:0.1:10; ‬‬ ‫;)‪>>y=sin(x‬‬ ‫;)‪>>z=cos(x‬‬ ‫‪>>plot(x,y,x,z,’r’);  ‬‬

‫دﻣﺞ‪ ‬ﻣﺠﻤﻮﻋﺔ‪ ‬ﺧﺼﺎﺋﺺ‪ ‬ﻟﺨﻂ‬ ‫اﻟﺮﺳﻢ‪ ‬‬

‫اﻟﺮﺳﻮم‪ ‬اﻹﺣﺼﺎﺋﻴﺔ‬ ‫‪Statistical Plots‬‬

‫رﺳﻢ‪ ‬اﻹﺷﺎرات‬ ‫اﻟﻤﺘﻘﻄﻌﺔ‪  ‬‬ ‫‪Plotting Discrete‬‬ ‫‪Signals‬‬

‫ﻗﻄﺎﻋﺎت‪ ‬ﻣﻦ‪ ‬اﻟﺪاﺋﺮة‪ ‬‬ ‫‪Pie Chart‬‬

‫‪>>plot(x,y,’g+’,‬‬ ‫‪x,z,’:’); ‬‬ ‫;]‪>>x=[8 17 21 18 6‬‬ ‫‪>>pie(x) ‬‬

‫اﻟﻤﺪرج‪ ‬اﻟﺘﻜﺮاري‪ ‬‬ ‫‪Bar Chart‬‬ ‫اﻹﺷﺎرات‪ ‬اﻟﻤﺘﻘﻄﻌﺔ‪ ‬‬ ‫‪Discrete Signals‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫‪>>bar(x) ‬‬ ‫>>‬ ‫;)‪>>x=linspace(0,2*pi,60‬‬ ‫;)‪x=linspace(0,2*pi,60‬‬

‫;)‪>>y=sin(x‬‬ ‫‪>>stem(x,y)  ‬‬

‫‪11‬‬

‫ي‪ ‬ﻢ‪ ‬رﺑﺘﺳﻨﻔﻢﻴ‪ ‬ﺬﺟ‪ ‬اﺪﻳﻷﺪ‪ ‬وإاﻟﻣﻰﺮ‪ ‬‬ ‫ﺿ‪ ‬ﺎﻓ‪ ‬ﺔﻟ‪ ‬ﺬأا‪ ‬ﻗ‬ ‫اﻧﻟﻔﺮﺲﺳ‪ ‬اﻢﻟ‪ ‬ﻨوﺎإﻓﺬة‬

‫ﺣﺴﺐ‪ ‬اﻟﺘﺮﺗﻴﺐ‪ ‬اﻟﻤﻮﺿﺢ‪ ‬‬

‫أﻳﻀﺎ‪ ‬ﻳﻤﻜﻦ‪ ‬أن ﻳﺘﻢ‪ ‬دﻣﺞ‪ ‬اﻟﺮﺳﻮم‬ ‫ﺑﺎﺳﺘﺨﺪام‪  ‬ﻩﺬﻩ ‪ ‬اﻟﻄﺮﻳﻘﺔ‪ ‬اﻟﻤﺨﺘﺼﺮة‪  ‬‬ ‫ﺁﺬﻟﻚ‪ ‬ﻳﻤﻜﻦ‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼب دﻣﺞ‪ ‬اﻟﺮﺳﻮم‬ ‫وﺗﻐﻴﻴﺮ‪ ‬ﺧﺼﺎﺋﺺ‪ ‬اﻟﺮﺳﻢ‪ ‬ﻟﻜﻞ‪ ‬ﻣﻨﺤﻨﻰ‬ ‫ﺑﺸﻜﻞ‪ ‬ﻣﺒﺎﺷ‬ ‫إﻧﺸﺎ ‪ ‬ﻣﺘﻐﻴﺮ )‪ (x‬وﻣﻦ‪ ‬ﺛﻢ‪ ‬رﺳﻢ‪ ‬اﻟﻨﺴ‬ ‫اﻟﻤﺌﻮﻳﺔ‪ ‬ﻟﻌﻨﺎﺻﺮﻩ‪ ‬ﻋﻠﻰ‪ ‬ﺷﻜﻞ‪ ‬ﻗﻄﺎﻋﺎت‪ ‬‬ ‫ﻣﻦ‪ ‬اﻟﺪاﺋﺮة‪ ‬‬ ‫رﺳﻢ‪ ‬اﻟﻨﺴﺐ‪ ‬اﻟﻤﺌﻮﻳﺔ‪ ‬ﻟﻌﻨﺎﺻﺮ‪ ‬اﻟﻤﺘﻐﻴﺮ‬ ‫)‪ (x‬ﻋﻠﻰ‪ ‬ﺷﻜﻞ‪ ‬ﻣﺪرج‪ ‬ﺗﻜﺮار ‪ ‬‬ ‫إﻧﺸﺎ ‪ ‬اﻹﺷﺎرات‪ ‬اﻟﻤﺘﻘﻄﻌﺔ )‪ (x‬و )‪(y‬‬ ‫وﻣﻦ‪ ‬ﺛﻢ‪ ‬رﺳﻢ‪ ‬ﺗﻠﻚ‪ ‬اﻹﺷﺎرات‪  ‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫‪‬ﺟ‪‬ﺪ‪‬و‪‬ل‪ ‬اﻷﻟﻮان )‪ (Color‬اﻟﻤﻌﺮﻓﺔ‪ ‬ﻓﻲ‪ ‬رﺳﻢ‪ ‬اﻟﻤﻨﺤﻨﻴ‬

‫‪ ‬‬

‫‪ ‬اﻟﺮﻣﺰ‪ ‬اﻟﻤﺴﺘﺨﺪم‬ ‫اﻟﻠﻮن‪ ‬‬

‫‪c‬‬

‫‪r‬‬

‫‪g‬‬

‫‪b‬‬

‫أﺻﻔ ‪ ‬‬

‫ﻣﺎﺟﻴﻨﺘ ‪ ‬‬

‫ﺳﻤﺎو ‪ ‬‬

‫أﺣﻤ ‪ ‬‬

‫أﺧﻀ ‪ ‬‬

‫أزر ‪ ‬‬

‫أﺑﻴ‬

‫‪Color ‬‬

‫‪ yellow‬‬

‫‪ magenta‬‬

‫‪ cyan‬‬

‫‪ red‬‬

‫‪ green‬‬

‫‪ ‬‬ ‫‪ blue‬‬

‫‪ white‬‬

‫‪y‬‬

‫‪m‬‬

‫‪w‬‬

‫‪‬ﺟ‪‬ﺪ‪‬و‪‬ل ﻧﻮاع‪ ‬اﻟﺨﻄﻮط )‪ (Line Style‬اﻟﻤﻌﺮﻓﺔ‪ ‬ﻓﻲ‪ ‬رﺳﻢ‪ ‬اﻟﻤﻨﺤﻨﻴ‬ ‫‪ ‬اﻟﺮﻣﺰ‪ ‬اﻟﻤﺴﺘﺨﺪم‬ ‫ﻧﻮع‪ ‬اﻟﺨﻂ‪ ‬‬ ‫‪Line Style‬‬

‫‪-‬‬

‫ﻣﺘﺼ ‪ ‬‬ ‫‪ solid‬‬

‫‪:‬‬

‫ﻧﻘ ‪ ‬‬ ‫‪ dotted‬‬

‫‪-.‬‬

‫ﻧﻘﻄﺔ‪ ‬وﺷﺮﻃ ‪ ‬‬ ‫‪ dash dotted‬‬

‫‪k‬‬ ‫‪ ‬‬

‫‪--‬‬

‫ﺷﺮﻃ ‪ ‬‬ ‫‪ dashed‬‬

‫اﻟﺮﻣﺰ‪ ‬اﻟﻤﺴﺘﺨﺪ‬

‫اﻟﻮﺻ ‪ ‬‬ ‫إﺷﺎرة‪ ‬زاﺋ ‪ ‬‬ ‫داﺋﺮ ‪ ‬‬ ‫ﻧﺠ ﻤ ‪ ‬‬ ‫ﻧﻘﺎ ‪ ‬‬ ‫إﺷﺎرة‪ ‬ﺗﻘﺎﻃ ‪ ‬‬ ‫ﻣﺮﺑ ‪ ‬‬ ‫ﻣﻌ ﻴ ‪ ‬‬ ‫ﻣﺜﻠﺚ‪ ‬ﻳﺸﻴﺮ‪ ‬ﻟﻸﻋﻠ ‪ ‬‬

‫‪Plus sign‬‬ ‫‪Circle‬‬ ‫‪Asterisk‬‬ ‫‪Point‬‬ ‫‪Cross‬‬ ‫‪Square‬‬ ‫‪Diamond‬‬ ‫‪Upward-pointing triangle‬‬

‫‪v‬‬ ‫>‬ ‫>edit ‬‬

‫ﻗﻢ‪ ‬ﺑﻔﺘﺢ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﺘﺤﺮﻳﺮ )‪(Editor‬‬ ‫وذﻟﻚ‪ ‬ﻟﻜﺘﺎﺑ ‪ ‬ﻣﻠﻒ )‪ (M-File‬‬ ‫ﻗﻢ‪ ‬ﺑﻜﺘﺎﺑﺔ‪ ‬اﻷواﻣﺮ‪ ‬اﻟﻤﻮﺿﺤﺔ‪ ‬ﻓﻲ‬ ‫ﺷﺎﺷﺔ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﺘﺤﺮﻳﺮ‪(Editor) ‬‬ ‫وﺑﻌﺪ‪ ‬اﻻﻧﺘﻬﺎ ‪ ‬ﻗﻢ‪ ‬ﺑﺤﻔﻆ‪ ‬اﻟﻤﻠﻒ‪ ‬ﺑﺎﺳﻢ‪ ‬‬ ‫)‪  (script.m‬‬ ‫ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‪ ‬اﻟﺒﺮﻧﺎﻣﺞ )‪(script.m‬‬ ‫وذﻟﻚ‪ ‬ﺑﻜﺘﺎﺑﺔ‪ ‬اﺳﻢ‪ ‬اﻟﻤﻠﻒ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‬ ‫اﻷواﻣﺮ‪ ‬ﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪  ‬‬ ‫ﻟﺘﻌﻠﻢ‪  ‬ﺁﻴﻔﻴﺔ‪ ‬اﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ )‪ (for ‬ﻗﻢ‬ ‫ﻗﻢ‪ ‬ﺑﻔﺘﺢ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﺘﺤﺮﻳﺮ‪(Editor) ‬‬ ‫ﻹﻧﺸﺎ ‪ ‬اﻟﻤﻠ )‪( program1.m‬‬ ‫واﻟﺬي‪ ‬ﻳﺤﺘﻮي‪ ‬ﻋﻠﻰ‪ ‬اﻷواﻣﺮ‬ ‫اﻟﻤﻮﺿﺤﺔ‪ ‬ﺛﻢ‪ ‬ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‪ ‬اﻟﺒﺮﻧﺎﻣﺞ ‪ ‬‬ ‫ﻗﻢ ﺑﺈﺟﺮا ‪ ‬اﻟﺘﻌﺪﻳﻼت‪ ‬اﻟﻤﻮﺿﺤﺔ‪ ‬ﻋﻠﻰ‬

‫‪for‬‬ ‫‪i=1:10‬‬ ‫;)‪x(n,i)=sin(pi*n/10‬‬ ‫‪end‬‬ ‫‪end‬‬ ‫‪x ‬‬

‫ﻧﻔﺲ‪ ‬اﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﺴﺎﺑﻖ‪ ‬واﻟﻤﺴﻤﻰ‪ ‬‬ ‫)‪ ( program1.m‬ﺑﻮاﺳﻄﺔ ﺑﺮﻧﺎﻣﺞ‬ ‫اﻟﺘﺤﺮﻳﺮ‪ (Editor) ‬وﻣﻦ ﺛﻢ‪ ‬ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‬ ‫اﻟﺒﺮﻧﺎﻣﺞ‪  ‬‬ ‫ﻟﺘﻌﻠﻢ‪  ‬ﺁﻴﻔﻴﺔ‪ ‬اﺳﺘﺨﺪام‪ ‬اﻷﻣﺮ )‪(While‬‬ ‫ﻗﻢ‪ ‬ﺑﻔﺘﺢ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﺘﺤﺮﻳﺮ )‪(Editor‬‬ ‫ﻹﻧﺸﺎ ‪ ‬اﻟﻤﻠ )‪( program2.m‬‬ ‫واﻟﺬي‪ ‬ﻳﺤﺘﻮي‪ ‬ﻋﻠﻰ‪ ‬اﻷواﻣﺮ‬ ‫اﻟﻤﻮﺿﺤﺔ‪ ‬ﺛﻢ‪ ‬ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‪ ‬اﻟﺒﺮﻧﺎﻣﺞ‪  ‬‬

‫ﻣﻠﻒ‪ ‬اﻷواﻣﺮ‪ ‬‬ ‫)‪The Script File (M-File‬‬

‫;‪x=pi/100:pi/100:10*pi‬‬ ‫;‪y=sin(x)./x‬‬ ‫)‪plot(x,y‬‬ ‫‪grid on ‬‬

‫ﺗﺸﻐﻴﻞ‪ ‬ﻣﻠﻒ‪ ‬اﻷواﻣﺮ‪ ‬‬ ‫‪Executing the Script File‬‬

‫‪>>script ‬‬

‫اﻷﻣﺮ )‪(For ‬‬ ‫‪For Loop‬‬

‫‪for n=1:10‬‬ ‫;)‪x(n)=sin(pi*n/10‬‬ ‫‪end‬‬ ‫‪x ‬‬ ‫‪for n=1:10‬‬

‫اﻷﻣﺮ )‪(For ‬‬ ‫‪ Nested For Loop‬‬ ‫‪Loop‬‬

‫‪a=1‬‬ ‫‪while a>for i=1:10‬‬ ‫‪program4‬‬ ‫‪end ‬‬

‫ﺗﺸﻐﻴﻞ‪ ‬ﻣﻠﻒ‪ ‬اﻷواﻣﺮ‪ ‬‬ ‫‪Executing the Script File‬‬

‫ﺁﺘﺎﺑﺔ‪ ‬داﻟﺔ‬ ‫‪Writing a Function‬‬

‫اﺳﺘﺪﻋﺎ ‪ ‬اﻟﺪاﻟﺔ‬ ‫‪Calling the Function‬‬ ‫اﻟﺪاﻟﺔ‪ ‬‬ ‫‪The Function‬‬

‫ﺁﺘﺎﺑﺔ‪ ‬داﻟﺔ‪ ‬أﺧﺮى‬ ‫‪Writing another‬‬ ‫‪Function‬‬

‫‪function‬‬ ‫)‪[u,v]=myfunc(a,b‬‬ ‫;‪u=a+b‬‬ ‫‪v=a-b; ‬‬

‫اﻟﻻﻤﺳﻮﺘﺪﺿﻋﺎﺤﺔ‪  ‬اﻟ‪ ‬ﺪاﻟﺔ‪ ‬ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‪ ‬اﻷﻣﺮ‬ ‫‪ >>[u,v]=myfunc(3,7)  ‬اﻟﻤﻮﺿﺢ‪ ‬وذﻟﻚ‪ ‬ﺑﻜﺘﺎﺑﺔ‪ ‬اﺳﻢ‪ ‬ﻣﻠﻒ‪ ‬اﻟﺪاﻟﺔ‪ ‬‬ ‫ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ‪ ‬ﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪  ‬‬

‫)‪function y=stat(a,b‬‬ ‫‪if a>b‬‬ ‫)’‪disp(‘a is greater than b‬‬ ‫‪elseif a>stat(5,3‬اﻟﻤﻮﺿﺤﺔ‪ ‬وذﻟﻚ‪ ‬ﺑﻜﺘﺎﺑﺔ‪ ‬اﺳﻢ‪ ‬ﻣﻠﻒ‬ ‫)‪>>stat(6,6‬‬ ‫‪ >>stat(2,8)  ‬اﻟﺪاﻟﺔ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ‪ ‬ﻟﺒﺮﻧﺎﻣﺞ‪ ‬‬ ‫اﻟﻤﺎﺗﻼب‪  ‬‬

‫اﺳﺘﺪﻋﺎ ‪ ‬اﻟﺪاﻟﺔ‬ ‫‪Calling the Function‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫ﻗﻢ‪ ‬ﺑﺘﻨﻔﻴﺬ‪ ‬اﻟﺒﺮﻧﺎﻣﺞ )‪( program4‬‬ ‫ﻟﻌﺪد‪ ‬ﻋﺸﺮ‪ ‬ﻣﺮات‪ ‬ﻣﺘﺘﺎﻟﻴﺔ‪ ‬وذﻟﻚ‪ ‬ﺑﻜﺘﺎﺑﺔ‬ ‫ﻩﺬﻩ‪ ‬اﻷواﻣﺮ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻷواﻣﺮ‪ ‬‬ ‫ﻟﺒﺮﻧﺎﻣﺞ‪ ‬اﻟﻤﺎﺗﻼب‪  ‬‬ ‫ﻗﻢ‪ ‬ﺑﻔﺘﺢ‪ ‬ﺑﺮﻧﺎﻣﺞ‪ ‬اﻟﺘﺤﺮﻳﺮ )‪(Editor‬‬ ‫ﻹﻧﺸﺎ ‪ ‬ﻣﻠﻒ‪ ‬اﻟﺪاﻟ )‪(myfunc.m‬‬ ‫واﻟﺬي‪ ‬ﻳﺤﺘﻮي‪ ‬ﻋﻠﻰ‪ ‬اﻷواﻣﺮ‬

‫‪14‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

‫‪ ‬‬

‫ﻣﻘﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬اﻟﺒﺮﻣﺠﺔ‪ ‬ﺑﺎﻟﻤﺎﺗﻼب‪ ‬‬

‫‪Introduction to Matlab‬‬

‫اﻟﻌﻼﻗﺎت‪ ‬اﻟﻤﻨﻄﻘﻴﺔ )‪ (Logical Expression‬اﻟﻤﻌﺮﻓﺔ‪ ‬ﻓﻲ اﻟﻤﺎﺗﻼ‬ ‫‪‬ﺟ‪‬ﺪ‪‬و‪‬ل ﻋﻼﻗﺎت‪ ‬اﻟﻤﻘﺎرﻧ‬ ‫‪ ‬اﻟﺮﻣﺰ‪ ‬اﻟﻤﺴﺘﺨﺪم‬

‫)‪ (Relation Operators‬‬

‫وﺻ ‪ ‬اﻟﻌﻼﻗ‬ ‫ﻳﺴﺎو ‪ ‬‬ ‫ﻻ‪ ‬ﻳﺴﺎو ‪ ‬‬ ‫أ ﻗﻞ ‪ ‬‬ ‫أﻗﻞ‪ ‬أو‪ ‬ﻳﺴﺎو ‪ ‬‬ ‫أﺁﺒ ‪ ‬‬ ‫أﺁﺒﺮ‪ ‬أو‪ ‬ﻳﺴﺎو ‪ ‬‬

‫==‬ ‫=~‬ ‫‬

‫‪ ‬‬

‫‪Description‬‬ ‫‪Equal to‬‬ ‫‪ Not equal‬‬ ‫‪Less than‬‬ ‫‪Lese than or equal‬‬ ‫‪Greater than‬‬ ‫‪Greater than or equal‬‬

‫ﺟﺪ‪‬و‪‬ل اﻟﻌﻼﻗﺎت اﻟﻤﻨﻄﻘﻴﺔ )‪ (Logical Operators‬‬ ‫‪ ‬‬

‫‪ ‬اﻟﺮﻣﺰ‪ ‬اﻟﻤﺴﺘﺨﺪم‬ ‫&‬ ‫|‬ ‫~‬ ‫‪xorr‬‬ ‫‪xo‬‬

‫وﺻ ‪ ‬اﻟﻌﻼﻗ‬ ‫اﻟﻌﻼﻗﺔ " "‪ ‬‬ ‫اﻟﻌﻼﻗﺔ "أ "‪ ‬‬ ‫اﻟﻌﻼﻗﺔ " "‪ ‬‬ ‫اﻟﻌﻼﻗﺔ )‪ (xor ‬‬

‫‪Description‬‬ ‫‪And‬‬ ‫‪or‬‬ ‫‪ Not‬‬ ‫‪XOR‬‬

‫ﻣﺜﻠﺔ‪ ‬اﻻﺳﺘﺨﺪام‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼب‬ ‫‪ ‬ﻃﺮﻳﻘﺔ‪ ‬اﻟﺘﻤﺜﻴﻞ‪ ‬ﻓﻲ‪ ‬اﻟﻤﺎﺗﻼ‬

‫‪ ‬اﻟﻘﻴﻢ‪ ‬اﻟﺮﻳﺎﺿﻴﺔ‬ ‫‪ x ∉ [0,5]  ‬‬

‫)‪i f ( x>=0) & ( x=0) & ( x>clc‬‬

‫‪>>clear all‬‬

‫اﻋﺪاد‪ ‬د‪ /‬ﺧﺎﻟﺪ‪ ‬ﻋﺒﺪ‪ ‬اﻟﺤﻤﻴﺪ‪ ‬اﻟﻬﻨﺪ ‪ ‬‬

‫ﻣﺴﺢ‪ ‬ﻧﺎﻓﺬة‪ ‬إدﺧﺎل‪ ‬اﻷواﻣﺮ‬ ‫ﻣﺴﺢ‪  ‬ﺁﺎﻓﺔ‪ ‬اﻟﻤﺘﻐﻴﺮات‪ ‬واﻟﺪوال‬ ‫اﻟﻤﺴﺘﺨﺪﻣﺔ‪ ‬ﻓﻲ‪ ‬ﻧﺎﻓﺬة‪ ‬اﻟﻤﺘﻐﻴﺮات‪ ‬‬ ‫ﻣﻦ‪  ‬ذاﺁﺮة‪ ‬اﻟﺤﺎﺳﺐ‬

‫‪16‬‬

‫‪ ‬‬

‫‪Dr. Khalid A. Al-Hindi‬‬

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF