Finite element programming with Matlab Lecture12 Logical Functions

Finite element programming with Matlab Lecture-12 Logical Functions & Selection Structures with MATLAB Dr. Reem Alsehnawi


Selection Structures ﺍﻻﺧﺘﻴﺎﺭ ﺗﺮﻛﻴﺒﺎﺕ : ﺍﻟﺒﺴﻴﻄﺔ if ﻋﺒﺎﺭﺓ 1 if condition code end : if/else ﺗﺮﻛﻴﺐ 2 if condition code_1 else code_2 end 3

Selection Structures ﺍﻻﺧﺘﻴﺎﺭ ﺗﺮﻛﻴﺒﺎﺕ : if/elseif ﺗﺮﻛﻴﺐ 3 if condition_1 code_1 elseif condition_2 code_2 elseif condition_3 code_3 else code_4 end 4

![Selection Structures ﺍﻻﺧﺘﻴﺎﺭ function [x 1 x 2] = root 2 nd(a, b, c) Selection Structures ﺍﻻﺧﺘﻴﺎﺭ function [x 1 x 2] = root 2 nd(a, b, c)](http://slidetodoc.com/presentation_image/206802a2df8e0022e101067d1d24a7a8/image-6.jpg)
Selection Structures ﺍﻻﺧﺘﻴﺎﺭ function [x 1 x 2] = root 2 nd(a, b, c) % root 2 nd(a, b, c) computes the roots of the % second order equation a x^2 + b x + c = 0 ﺟﺬﻭﺭ If a==0 & b==0 x 1 = Na. N; x 2 = Na. N; disp('This equation is degenerate!') elseif a==0 x 1 = -c/b; x 2 = Na. N; disp('This equation is linear and there is a single root. ') else d 2 = delta 2(a, b, c); x 1 = (-b+d 2)/(2*a); x 2 = (-b-d 2)/(2*a); disp('There are two roots for this equation. ') end function d 2 = delta 2(a, b, c) % Sub function to calculate delta square root d 2 = sqrt(b^2 -4*a*c); ﺗﺮﻛﻴﺒﺎﺕ : ﻣﺴﺄﻠﺔ ﻟﺤﺴﺎﺏ root 2 nd ﺍﻟﻤﻄﻠﻮﺏ ﻛﺘﺎﺑﺔ ﺗﺎﺑﻊ ﺑﺎﺳﻢ ﻣﻌﺎﺩﻟﺔ ﻣﻦ ﺍﻟﺪﺭﺟﺔ ﺍﻟﺜﺎﻧﻴﺔ 6


![Repetition Structures ﺗﺮﺍﻛﻴﺐ ﺍﻟﺘﻜﺮﺍﺭ for counter = [vector] commands end : (for loops) for Repetition Structures ﺗﺮﺍﻛﻴﺐ ﺍﻟﺘﻜﺮﺍﺭ for counter = [vector] commands end : (for loops) for](http://slidetodoc.com/presentation_image/206802a2df8e0022e101067d1d24a7a8/image-9.jpg)
Repetition Structures ﺗﺮﺍﻛﻴﺐ ﺍﻟﺘﻜﺮﺍﺭ for counter = [vector] commands end : (for loops) for ﺣﻠﻘﺎﺕ 9

Repetition Structures ﺗﺮﺍﻛﻴﺐ ﺍﻟﺘﻜﺮﺍﺭ initialization while criterion commands updating end : (while loops) while ﺣﻠﻘﺎﺕ 10

Repetition Structures ﺗﺮﺍﻛﻴﺐ ﺍﻟﺘﻜﺮﺍﺭ k= k= a= : (while loops) while ﺣﻠﻘﺎﺕ : ﻣﺜﺎﻝ 0 k=0 while 1 2 end 2 2 k<3 k=k+1 a(k)=2^k 4 3 2 4 8 11

- Slides: 12