1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal 14300 Pulau Pinang Week 10.

Slides:



Advertisements
Similar presentations
Introduction to MATLAB The language of Technical Computing.
Advertisements

Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Flow Charts, Loop Structures
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 3.
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
CIS 101: Computer Programming and Problem Solving Lecture 7 Usman Roshan Department of Computer Science NJIT.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
Concatenation MATLAB lets you construct a new vector by concatenating other vectors: – A = [B C D... X Y Z] where the individual items in the brackets.
Matrix Mathematics in MATLAB and Excel
CE 311 K - Introduction to Computer Methods Daene C. McKinney
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Matlab intro The Environment
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
Chapter 10 Review: Matrix Algebra
Creating scalars, vectors, matrices Ex1 & 2. Dot Product & Cross Product Ex3. Plotting Graphs Ex4. Conversion Table Ex5. Plotting functions Finishing Ex4.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 1.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
1 Tips for solving Project 1 Reactor SO 3 SO 2 +O 2.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 9.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 4.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Lecture 28: Mathematical Insight and Engineering.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 9.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 11.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2012.
3.6 Solving Systems Using Matrices You can use a matrix to represent and solve a system of equations without writing the variables. A matrix is a rectangular.
Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 6.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Today we will learn MATLAB Click Start  All programm  Class Software  Matlab This command window will be seen with a prompt sign >> Any command can.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
ECE 1304 Introduction to Electrical and Computer Engineering
EMT 101 – Engineering Programming
L – Modeling and Simulating Social Systems with MATLAB
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
MATLAB Tutorial Dr. David W. Graham.
Communication and Coding Theory Lab(CS491)
Demo of Basic Matlab Features
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Matlab Basics Tutorial
Presentation transcript:

1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10

2 What is Matlab? C++ is a programming language but Matlab is software which are used for many engineering applications Matlab also has its own programming language Matlab has its own interpreter, no need to compile or link source codes Data types are not declared–MATLAB: automatically assigns the appropriate type when you initialize a variable

3 Matrix Laboratory? MATrix LABoratory MATLAB performs matrix (or vector) manipulations and computations Output to screens are automatic (no need cout) Input to code-use input Type help input to learn more

4 Vectors and Matrices Elements in an array can be assessed using indices Example: b = [ ] Type b(2) in MATLAB will give you 5 b(4) gives you 9 Type b(2:4) is an array [ 5 6 9] b(3:end) gives you [ ]

5 Matrices (2D Array) Given a 3 x 3 matrix A = [ 3 4 5; 8 6 2; 8 6 2; ] ] A(1,1) is 3 A(1,3) is 5 A(2,:) is a 1D (1 by 3) array of [8 6 2] A(:,2) is a 1D (3 by 1) array of [4; 6; 9]

6 Operators sum(x); max(x), min(x), mean(x) sum of matrices or vectors vector multiplication:dot product vs. vector product always be careful with the operators * and.* a*b is totally different than a.*b matrix multiplication; matrix products transpose of a matrix: use ’

7 Linear Algebra Example Solving a system of linear equations: Ax = b matrix vector multiplications two ways of solving a system of equations: (i) x=inv(A)*b or (i) x=inv(A)*b or (ii) x=A\b (ii) x=A\b See Tutorial exercise 2

8 Control Structures If-else statements (similar to C++) The format for switch case: Note that cannot be a range like in the if branch. This is a limitation of case switch switch case case statement statement case case statement statement otherwise otherwise statement statement end end

9 For Loop in Matlab Example with the dot product operations of vectors a and b of sizes n = 1000 sum = 0 sum = 0 for i = 1:1:1000 for i = 1:1:1000 sum = sum + a(i)*b(i) sum = sum + a(i)*b(i) end end

10Tutorial Construct a vector of with range with increment of 0.1. Solution: In Matlab, this can be done by setting X= [-1:0.1:1] Do-It-Yourself-Exercise 1. Determine another array 2. Next, determine the derivative 3. Plot the functions using plot(X,Y1,XY2)

11 %There is no initial Declaration or any include required for Matlab programing. Any variables used will be automatically declared by Matlab X=[-1:0.1:1]; %by including a “semicolon”, the output will %not be shown in the Command Window Y1=X.^2; %notice the used of “.^” instead of only “^” Y2=gradient(Y1); %command to find the gradient plot(X,Y1,X,Y2) %command to plot a graph legend('Y1','Y2') %command for the graph’s label

12 Exercise 1 Find the slope of a function F=cos x * exp(2x)* x^3 and plot the slope between [0, 3]. Plot both the slope and the function F on the same plot.

13 Exercise 2 Using subroutines, write a MATLAB program to solve (i) an arbitrary matrix problem A= M*N where M and N are matrices in which you need to input the numbers on your screen. Note M and N has a size mxm. (ii) Finding an inverse of the matrix

14 clc; %Clear the Command Window clear; %Clear all the previous saved data m=input('Enter number of rows : '); n=input('Enter number of colums : '); fprintf('\nEnter the element values for Matrix A\n'); %output the text, same as cout for i = 1:m %using 'for' loop, for j = 1:n fprintf('Enter element for A[%d,%d] : ',i,j); A(i,j) = input(''); end %to end the 'for' loop end A %to display back the Matric A, just put its name %WITHOUT SEMICOLON at the end fprintf('\n\nEnter the element values for Matrix B\n'); for i = 1:m for j = 1:n fprintf('Enter element for B[%d,%d] : ',i,j); B(i,j) = input(''); end B