مقدمة. Matlab. ! ا%$#"ام (Command Window) (M-File) ا (Functions) ا (Scripts)

Similar documents
۲۷۹۶ 0 "' ی " #! ۴۳ و م د ; < : ی"98! ی"#"!

**!!!"ﻛﺗ ﺎﻣ 'ﺧ)*!+ﻣﻠﺳﻣﻟ/ ءﺎﻣ1 **! 1+3ﻣ!ﻣ 45 6)+ﺻﻧﻟ/ 9ﺎ:ﻧﻠﻟ 4"ﻘ+" ﺎ+)"ﺳ ﻰﻠﻋ )ﻣﺂﺗ+ 9ﻟﺎﻌﻟ/

Rogue Counrty and Potential Cooperation: the United States and Sudan and Feasible Economic Partnership

UNIVERSITY OF CALICUT M.A. ARABIC (CCSS)

FAST! Tajweed Intensive Workshop! Rules of Noon Sakinah & Tanween Part 1

قسم الفيزياء والرياضيات الهندسية الخطة البحثية للقسم فى خمس سنوات ٢٠١٤ ٢٠١٨

Unit 1: CD1 Track 08. [pause] Hello and welcome. [pause] Hello to you, talking to a female. [pause] [pause] M1 Good morning

Mat. No The Organisational Culture and Organisational Loyalty, and Its Impact in Empowering the Workers in Anbar Governorate Health Sector

ا اتا باز واارا. [ The relationship between the psychological needs of the IDPs students and academic achievement ]

DRAMA AND SHORT STORY

Assessing the Viability of Investment in Sudan ( )

3:00 م. The Way Station


Noon Sakinah and Tanween. Chapter 5

Micrometer Gravity in Sky

Maghreb Review of Vol 03 - N 02 Economics and Management September تا 0 ةوا>- - CDوا&اع- اFGHا E

(CHAPTER 8) BASIC CONCEPTS

א א א K א א א א א א א א א א א -١ -

Geology Qur an English Arabic Math

DESIGN AND CONSTRUCTION OF A WIND TUNNEL FOR ENVIRONMENTAL FLOW STUDIES

Chapter 2 Analysis of structures

PDF !" ( 3 ) Word # $ %& '( ) ( *

Experimental Study of the Performance of Compound Parabolic Concentrating Solar Collector

Problem 1. Produce the linear and quadratic Taylor polynomials for the following functions:

أq ا" ct8 ا" o >تا"! 2 JiS3 ا" 2 دي ctا WXYاV.لا" oة

Downloaded from pdmag.info at 18: on Friday March 22nd 2019

ا اع ط د اد - ااق. [ Algae Spices list of Tigris River within Baghdad city Iraq ]

Experimental and Theoretical Study for Performance Enhancement of Air Solar Collectors by Using Different Absorbers

The Role of Second Legislative Council in the Jordanian legislative process

Synthesis and Spectral Characterization of some Fused Pyrimidine Thiones

P U N J A B EDUCATION FOUNDATION

Horizontal Alignment Design:

GEOTECHNICAL SUBSOIL PROPERTIES FOR WASIT GOVERNORATE

Investigation into Deformation Monitoring of Mosul Dam

Minorities and their Impact on the Stability of the. (Iraq s Kurds as an Example)

Physics. Grade 10 Advanced Level. Handling physical quantities

International Journal of Scientific & Engineering Research, Volume 7, Issue 2, February ISSN

The Effect of Loom Speeds and Shed Heights on Beating Force

Embryology of the Muscular System

FLOW CHARACTERISTICS IN COMPOUND OPEN CHANNELS WITH ONE FLOODPLAIN

Christ is Born Glorify Him. ا لمسيحولد.. فمجدوه.

OPTIMAL SHIFTING OF EIGENVALUES FOR LOAD FREQUENCY CONTROL SYSTEMS

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,

دا no یاری. f تاب % & '()* !" #

with a font size 28 LEMON PEEL AS NATURAL BIOSORBENT TO REMOVE FROM SIMULATED WASTEWATER Space with a font size 24

Effect of Salinity on Growth and Some Physiological Characteristics of Broccoli Brassica oleracea var. Italica L. plants.

STRESSES IN CONCRETE PAVEMENT SLABS ON REISSNER'S FOUNDATION SUBJECTED TO FLOATING TANDEM AXLES

Statistical methods. Mean value and standard deviations Standard statistical distributions Linear systems Matrix algebra

STUDY THE DETERIORATION OF GRANITE STATUES, KEMAN FARES EXCAVATIONS, FAYOUM, EGYPT

All living things, big and small, are known as organisms.

Study the effect of position on the time of astronomical twilight

Holiday Home-work NAME: STD: SEC:

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

Farooq s Oratory Speechen A stylistic Study :

( ) Iran's foreign Policy and its Impact on the Arab Gulf Security

University of Babylon,College of Education for pure science, Department of mathematics.

ANALYSIS OF DYNAMIC CHARACTERISTICS OF FLEXIBLE ROBOT ARM USING SYMBOLIC MANIPULATION

SLIDING MODE CONTROL OF LINEAR SYNCHRONOUS MOTOR SERVODRIVE

Two-pass heat-exchanger performance By programmable method

3 إنكليزي. 2- Example: gravity keeps us from floating off the ground. 3-Universe: everything that exists in space, including stars and planets.

The Reality of Chemical Safety and Security at Al-Qasim Green University and Future Directions

Matlab for Review. NDSU Matlab Review pg 1

Nizar Qabbani s Prose in Light of Sociolinguistics

A COMPUTATIONAL STUDY FOR DEVELOPMENT STAGES OF ELECTRICAL PRE- BREAKDOWN PHENOMENON OF ROD-PLANE AIR GAP

ACTIVITY OF ULTRAFINE FRACTION OF RADON PROGENY IN INDOOR AIR

Study of the Performance of Batch Reactive Distillation Column

Math Introduction to Numerical Methods - Winter 2011 Homework 2 Assigned: Friday, January 14, Due: Thursday, January 27,

Assignment 6, Math 575A

Abstract. The study reached some important recommendations, such as:

Confined Hydrogen Atom in HigherSpace Dimension under Pressure. Muzaian Shaqqur & Sami Al Jaber

ENGR Spring Exam 2

Improvement of Dynamic Buckling Behavior of Intermediate Aluminized Stainless Steel Columns

Conditions and Effects for the Early Termination of the Commercial Agency

Formulation and Solving Integer Programming Models by Using Microsoft Excel. Instructor.Mushtaq.T. Hussain

Abstract. initial phases uniformly distributed along the interval (0-2π). The matlab 6.1

2- Look at the following structure. Z represents any atom or group that can bond to the carbon atom of the carbonyl group

بزنبهه ریزی خطی و شبکه هب هبشوی نژاد

ESTIMATION OF HYPERBOLIC STRESS-STRAIN PARAMETERS FOR GYPSEOUS SOILS

فاطو حاجاسوعيلي چکيذ. T Eta اشگاى کليذي:

Chapter 1: Introduction

Computational Foundations of Cognitive Science

Optimization and Calculus

All Rights Reserved - Library of University of Jordan - Center of Thesis Deposit

New Correlation To Calculate Absolute Permeability From Gas Permeameter


Integration of Multivariate Statistical Process Control and Engineering Process Control

EEE161 Applied Electromagnetics Laboratory 1

SOLUTIONS to Exercises from Optimization

Abo Al-Qasim Ash-Shabi s Poetry from the Reception Theory Perspective

LAB 1: MATLAB - Introduction to Programming. Objective:

MODELLING HOURLY ATMOSPHERIC STABILITY AND MIXING HEIGHT USING METROLOGICAL SURFACE DATA

ANALYSIS OF CORONA DISCHARGE IN ELECTROSTATIC MOTOR GAPS

Matlab Section. November 8, 2005

Grade 2 Term 3 Portion Paper

Reducing Lost Circulation Problem by Using Rice Material

The International year of light 2015 The Open University animation Arabic translation

تيوگزافي علمي مشخصات فزدی نام خانوادگي: سيزك مليت: ايرا ی تاريخ تولذ: 1359/10/20 مذهة: شيع وضعيت تاهل: هتا ل دين: اسالم

On a Certain Subclass of Multivalent Functions. A Research Submitted by. Muntadher Ali Joudah. Supervised by Dr. Najah Ali Al -Ziadi

Topic 3. Matrix Operations Matrix & Linear Algebra Operations Element-by-Element(array) Operations

Political Development and its Role in the Stability of the Sultanate of Oman ( )

Transcription:

د آ ام ات

مقدمة Matlab (M-File)! ا%$#"ام (Command Window) ا ا (Functions) ا (Scripts) ٢

٣

البرامج النصية Scripts ( Scripts ) آ Blank M-file < اNew7 < File ا 3 453ا : 9 ة ا 4 ;ر.Editor اآ$> % ا$ 4 ت..Save ا 7 < File 3@ A 453ا ا<!=?4ا ( D آ$ ا%?4ا : : 9 ة Cا 9!@ (B4 ا 7 وا.Command Windows ا 7 H type 9!@ D ( (B4 ض G$; ا% ا4?. (١ (٢ (٣ (٤ (٥ ٤

البرامج النصية Scripts $#ا! ب ل( ١ ): %This Program calculates the area of a rectangle %First the length & width is assigned length_rect=6 width_rect=2 % The area is calculated based on the length &width area= length_rect* width_rect ا' ا:ول $98 +(/7 و 56 ا'& +&#أ آ $98 ';% +*(م ا'& %ب,')- ٦ و,/ ٢ و-& ه 2! ا'*. ٥

البرامج النصية Scripts ل( ٢ ): #$9+ ا'& ا' 8 '% '#< وا'@ج %This Program calculates the area of a rectangle %First the length & width is assigned length_rect = input( Enter the length of rectangle: ) width_rect= input( Enter the width of rectangle: ) % The area is calculated based on the length &width area= length_rect* width_rect; ا' C ' input +$ض ا' A ا K &س. : ) is disp( the area of rectangle I H ا' G ( disp(area) M>#C ا' ا'* G H+;@+ L ا' G @#م N ا' G %(ل ا' P)G (د $ض و C, disp +*(م ا' A Q +ر ا' G واة. C (اء آن %(ل أو F. ٦

البرامج النصية Scripts ل( ٣ ): #$9+ ا'& ا' 8 '% 8U ا'@ج %This Program calculates the area of a rectangle %First the length & width is assigned length_rect = input( Enter the length of rectangle: ) width_rect= input( Enter the width of rectangle: ) % The area is calculated based on the length &width area= length_rect* width_rect; fprintf( the area of rectangle is : % f \n, area) A/) 9 #ل %f Q ا'( VC و(,. +$ض ا' A fprintf ا' ا' N%G, و/ MUG ا'* ا'$#د+..#+#P 9 #ل \n Q ا W *ل ' ٧

البرامج النصية Scripts %#دات ا' A/)G ا:آ - وا C @#ا : ا' QU$G أ "اد L;; أ "اد ا!L ا45 ;رف و<"ة :; N%O% ا'; %d %f %c %s ٨

البرامج النصية Scripts ل( ٤ ) +*(م ا'& ا'' %ب ا'* G ا'*+& ': %the approximate value of integral I f(x)=1/x^3, x belong to [1 3] %First the vectors are assigned a=1; b=3; x=[a b]; fprintf( % f \n, x) y=x.^(-3); fprintf( % f \n, y) I=(b-a)*(y(1)+y(2))/2; %the approximate value of integral I. fprintf( the approximate value of integral :% f \n, I) ٩

١٠

البرامج النصية Scripts والرسوم البيانيةPlotting (١١ ٤٨) N G\ ا' A/)G ا'' ا'& +*(م ل( ٥ ) C %This is a really simple plot of just one point! %Create coordinate variables and plot a red star x=11; y=48; '(ن plot ا' G %ف * plot(x, y, 'r*').(١١ ٤٨) %Change the axes and label them axis([9 12 35 55]) xlabel('time') xlabel ylabel('temperature') %Put a title on the plot title('time and Temp') +a ا' A ' G %ور. H+وU ylabel U (ان 'C. +C ا' A ا: G N ا' A/)G title axis +%#د ا' A ا'* Q ا' G %ور. +a ا' A ١١

البرامج النصية Scripts والرسوم البيانيةPlotting %#دات ا:'(ان: ا'(ن ا'; ا'(ن ا';!@Cا m أزرق b y أ ST اL7! g k أ< 4 ا 7 %د r c اV7 ان w ١٢

البرامج النصية Scripts والرسوم البيانيةPlotting %#دات ا'(ز: ا'$ I ا'; ا'$ I ا'; s دا 5 ة o 4 * ( d N!%X G$ W) 4 %"ا% v h ر G$ W) < %4T 4 p (4 G$ W) > + إ 0 رة 4ا A X G$ W) - إ 0 رة ا]ح ^ x Oا x [3. ١٣

البرامج النصية Scripts والرسوم البيانيةPlotting %#دات أ(اع ا'@(ط: (ع ا'@ V [3$ \3@ [3$ \3@ 4$ ا'; --.- : - ١٤

البرامج النصية Scripts والرسوم البيانيةPlotting ل( ٦ ) +*(م ا'& ا'' C ٣ U%U ت x = 0:pi/100:2*pi; y1 = 2*cos(x); y2 = cos(x); y3 = 0.5*cos(x); plot(x,y1,'--',x,y2,'-',x,y3,':') xlabel('0 \leqx\leq2\pi') ylabel('cosine functions') title('typical example of multiple plots') ١٥

البرامج النصية Scripts والرسوم البيانيةPlotting 9 (ا A 5 #ة ' C (م ا'&: و 56, Figure Window N] آN ;$ت ا@: 9 ة %ا ^@ : 9 ة %ا Window Figure :ر_ : ا@: 9 ة Figure Window "4 @;@4ا ;ا? 4ا 3ا % T ]ط BCا a 4 %ا ر[ (4 G ض ا :;4ا ا 44 رة 4) : 9 ة ا% و: 3 $> ا 4 @;@ت : ا@: 9 ة ا' A clf figure hold on hold off grid on grid off Legend ١٦

١٧

المصفوفات Matrices ;"د rot90 $ "دي إذا آن إ: و%\ Te ا"د N ا4!: "ور ١٨٠ در "د ات ا"وران :4 4 ه 9 ا >>rot90(a,2) "ور 3 رب ا N :!4ا هN B4) C' وVC ذ' f C @#ام HG+ >>rot90(a, -1) آ? B4) < 9 ف @L )!: U HG+ W و# 2 ف آ G (د أو آ 'H C 2 ف HG+ >>A(:,2)=[] >>A(3,:)=[] ١٨

المصفوفات Matrices 3 A = 1 1 $دWت > إ+\د GP ه N HO) 4 ا 4 دiت [#ا $ا @" (B$ 3x 1 + 2x 2 x 3 = 10 -x 1 + 3x 2 + 2x 3 = 5 x 1 x 2 x 3 = -1 2 1 3 2 1 1 x x = x x 1 2 3 10 b = 5 1!ض: Ax=b أن :<$B (B4 95"@ ١٩

المصفوفات Matrices Ax=b A -1 Ax=A -1 b x=a -1 b :$ا ::! NB $دWت > إ+\د GP N> 4 ا 4 دiت [#ا %$#"ام 3 ب >> A = [ 3 2-1; -1 3 2; 1-1 -1]; >> b = [ 10; 5; -1]; >> x = inv(a)*b x = -2.0000 5.0000-6.0000 MATLAB : C% C[ (B4 ٢٠

٢١

الاختيار Selection 0 ط if ا'$&رة if ا'$&رة Cرات end 0 ط if else end Cرات( 1 ) Cرات( 2 ) if-else ٢٢

الاختيار Selection ا' i وط '& U ء %ج ذا ا'$ ji * ا' G $ Iت ا' QU$G ا' G $ ا' QU$G ا' G $ أآ& =< +وي أو أآ& > أlm => +وي أو أlm < W +وي == +وي ~= ا' UG * ا' G $ Iت ا' QU$G ا' G $ ا' QU$G ا' G $ أو أو L@ :!4ا && و & و L@ :!4ا!@ا ~ ٢٣

الاختيار Selection ا'* G '$#د+ H N G '25U ل( ١ ) اآ ا:وا ا' Iز ل آن ا' G *(م, W +وي ا' 5 x=input( x= ); y=input( y= ); if y~=0 div=x/y fprintf( %5.2f / %5.2f = % 5.2f \n, x,y,div) end ٢٤

الاختيار Selection ل( ٢ ) #$9+ ا' G ل ا' 8 %n Mo9 رC ' 9(/7 #م إ ا'* G إذا آن ا' G *(م, $#وم x=input( x= ); y=input( y= ); if y ~= 0 div = x/y fprintf( %5.2f / %5.2f = % 5.2f \n, x, y, div) else fprintf( the division has not been able \n ) end ٢٥

الحلقات Loops for ا'%* ا'$&رات اآ for ل 3ا = $;ل 3;ا Cرات end إ' Q ٥ H ا' Iز '%ب \ G (ع ا: #اد s=0; for i = 5 : 20 s = s + i ; end fprintf( The sum from 5 to 20 = %d\n,s) ل( ٣ ) ٢٠ ٢٦

0 ط while Cرات end while s=0; i=5; الحلقات Loops,N while ا'%* ا'%* وا C @#م ا' 8 ا' G ل #ل ل( ٤ ) while i<=20 s=s+i; end i=i+1; fprintf( The sum from 5 to 20 = %d\n,s) ٢٧

٢٨

) التوابع Functions Function M-file < ;ي \[#.$ا Function) آ A9 اNew7 < File ا 3 453ا mn : 9 ة ا 4 ;ر.Editor وه (١ ا% ا$ و%]ء ا#ج ا$و و%]ء NT"ا function[ output_args] = Untitled( input_args) %UNTITLED Summary of this function goes here % Detailed explanation goes here end m $ا $ا p و q! ا$ ٢٩

Functions عباوتلا تoI ل) آ A'ا Function) ( (١ < نأ نB %ا $ا هو r! %ا.?4ا (٢ C$ :إ $ا أ.ير$Tا (٣ ي; $ا 4 تارCا $ا <[ ( $ا.ه9!@ (٤ < نأ ي; $ا تارC ($ ء[%و ج#ا (٥ (B4 9!@ $ا ( D $آ G4%ا : ة9: او7ا Command Windows وأ (4? 4و ء[%ا (.(% ٢٦ ( )ا ٢٠١٢ ٣٠ ج 0ر.أ.ق

التوابع Functions 3 f(x)=x -1 ا' A %ب ا'' ا' A +*(م ل( ١ ) GK function [y ] = f( x ) %This function calculates the f(x)=x 3-1 y=x^3-1; end ٣١

التوابع Functions A9 HG+ آ ء دا< ا C # 9 A ($3D " (4 "$%i ء "$ 4ا A Tر $ا (ف Tرج ا4?) داT A "$ 4ا $ا (ف (4 r! (?4ا ٣٢

التابع الداخلي Internal Function ا' A +*(م ل( ٢ ) =x 0:2pi أ P H f(x)=sin(x) ا'' %ب ا' G\G (ع '(ا A function [sf ] = sumf( ) %This function calculates sum of sin(x) sf=0; x=0:pi/100:2*pi; for i=1:length(x) sf=sf+f(x(i)); end end function [y] = f( x ) y=sin(x); end اi % r! ($ ٣٣

التابع الخارجيFunction External <ر P ل( ٣ ) #$9+ ا' G ل ا' 8 '\$ ا' A function [sf ] = sumf( f ) %This function calculates sum of sin(x) sf=0; x=0:pi/100:2*pi; for i=1:length(x) sf=sf+feval(f,x(i)); end end sumf( sin ) "i A اi %$" ء ا#ر NB0 اi %$" ء ٣٤

رسم التوابع Drawing Functions HG/ 3 f(x)=x -1 ل( ٤ ) +*(م C ا' G \ل 10] [1 ا' A ا'' ا' A fplot('f ',[0,10], ':') axis([0 10 0 1000]) xlabel('0 \leq x \leq 10') ylabel('f(x)') title(' f(x)=x^3-1 ') ٣٥

٣٦

طريقة نيوتن Newton Method H9) *+- G+ ا' 2 ي ا' A function newton(f,df,x0,tol,n) %number of iterance iter=0; %the first value of function u=feval(f,x0); %the first value of function s derivative v=feval(df,x0); %the first error value err=abs(u/v); disp(' ') disp(' iter x f(x) df(x) xn+1-xn ') disp(' ') fprintf('%2.0f %12.6f %12.6f %12.6f\n',iter,x0,u,v) while (err>tol)&(iter<=n)&(v~=0) x1=x0-u/v; err=abs(x1-x0); x0=x1; u=feval(f,x0); v=feval(df,x0); iter=iter+1; fprintf('%2.0f %12.6f %12.6f %12.6f %12.6f\n',iter,x0,u,v,err) end if (v==0) disp(' division by zero') end if (iter>n) disp(' Method failed to converge') end ٣٧

طريقة نيوتن Newton Method H9) *+- 8&9 ل Q f= 2x3 1 أو ف ا df = 6 x2 ف ا n و =10 و tol=1e-04 x0=0.5 ا د " newton را! ا >> newton('f','df',x0,tol,n) - أن! +ل ا&%$() ا' واا' &%$ة >> newton('f','df',0.5,1e-04,10) 1 ه :./ 0 12 iter x f(x) df(x) xn+1-xn 0 0.500000-0.500000 2.000000 1 0.750000 0.125000 3.000000 0.250000 2 0.708333 0.003472 2.833333 0.041667 3 0.707108 0.000003 2.828431 0.001225 4 0.707107 0.000000 2.828427 0.000001 ٣٨

طرق ا يجاد الجذورMethod Finding Root NB Dق ( 3D إد ا 9 ور <%@4ا اآ$> $ا @? ا 4 ل.(ا! u ا 7 و A ) ا ا#D^. (ا! u ا() ا@ 3 ] ا($. (ا! u ا(() ا D3. (ا! u اا) u:) ("3ا."4ا ( ٤٠