280 likes | 542 Views
Numerical Analysis TA. Lesson 1: An Introduction to MATLAB Professor: Dr. Shahverdiani TA: Amir Mortazavi. What is MATLAB?. MATLAB is the language of technical computing. Why MATLAB?. MATLAB’s Application in Civil Engineering. Construction Management Environmental Engineering
E N D
Numerical Analysis TA Lesson 1: An Introduction to MATLAB Professor: Dr. Shahverdiani TA: Amir Mortazavi
MATLAB’s Application in Civil Engineering • Construction Management • Environmental Engineering • Structure Engineering • Earthquake Engineering • Hydraulics • Hydrology • Water and Waste water Management • Road and Transportation Engineering • Geotechnical Engineering
Arithmetic Operators • plus - Plus + • uplus - Unary plus + • minus - Minus - • uminus - Unary minus - • mtimes - Matrix multiply * • times - Array multiply .* • mpower - Matrix power ^ • power - Array power .^ • mldivide - Backslash or left matrix divide \ • mrdivide - Slash or right matrix divide / • ldivide - Left array divide .\ • rdivide - Right array divide ./
Relational Operators • eq - Equal == • ne - Not equal ~= • lt - Less than < • gt - Greater than > • le - Less than or equal <= • ge - Greater than or equal >=
Logical Operators • and - Element-wise logical AND & • or - Element-wise logical OR | • not - Logical NOT ~
Special Characters • colon - Colon : • paren - Parentheses and subscripting ( ) • paren - Brackets [ ] • paren - Braces and subscripting { } • punct - Decimal point . • punct - Continuation ... • punct - Separator , • punct - Semicolon ; • punct - Comment %
Special Characters (Continue) • punct - Invoke operating system command ! • punct - Assignment = • punct - Quote ' • transpose - Transpose .‘ Note: Capital and Small letters in MATLAB are different from each other.
Control Flow • break Terminate execution of for or while loop • case Execute block of code if condition is true • catch Handle error detected in try-catch statement • continue Pass control to next iteration of for or while loop • else Execute statements if condition is false • elseif Execute statements if additional condition is true • end Terminate block of code, or indicate last array index • error Display message and abort function • for Execute statements specified number of times • if Execute statements if condition is true • otherwise Default part of switch statement • parfor Parallel for-loop • return Return to invoking function • switch Switch among several cases, based on expression • try Execute statements and catch resulting errors • while Repeatedly execute statements while condition is true
Example 1 • برنامه ای با استفاده از زبان متلب بنویسید که بتواند نمودار تابع زیر را در بازه ای معین ترسیم کند. • F(x)=X2-2X+1
Homework AssignmentsDeadline: • برنامه ای با استفاده از زبان متلب بنویسید که بتواند ماکزیمم و مینیمم یک تابع درجه 3 را در بازه ای معین پیدا کند. • برنامه ای با استفاده از زبان متلب بنویسید که بتواند عکس العمل های تکیه گاهی یک تیر کنسول تحت اثر بار یکنواخت را محاسبه کند.