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

Slides:



Advertisements
Similar presentations
259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
Advertisements

Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
1.3 ARRAYS, FILES, AND PLOTS + FOURIER SERIES BY MR. Q.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 3.
1 G:\common\eng1102\1102_200508\02matlab\m10.functions.sxi Today's Agenda ● Introduce Matlab User Functions.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Lecture 14: M/O/F/ for Engineering Applications - Part 2 BJ Furman 28NOV2011.
1 -Defined Functions 1. Goals of this Chapter 2. General Concept 3. Advantages 4. How it works Programmer.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 1.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
1 Tips for solving Project 1 Reactor SO 3 SO 2 +O 2.
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.
Matlab Programming for Engineers Dr. Nidal Farhat Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
For Loops 1 ENGR 1181 MATLAB 8. For Loops and Looped Programming in Real Life Looping within programs has long been a useful tool for completing mundane.
Eng Ship Structures 1 Introduction to Matlab.
1 Discretization of Fluid Models (Navier Stokes) Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
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.
Numerical Solutions of Integral Equations and Associated Control and Estimation Problems Jeffrey Carroll, Sophomore Dr. S. A. Belbas.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
1 Computational Methods Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
1 Computational Methods II (Elliptic) Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal Pulau.
1 Discretization of Fluid Models (Navier Stokes) Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal.
1 Computational Methods II (Elliptic) Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal Pulau.
Post-Processing Output with MATLAB Claudia Fricke Institute of Petroleum Engineering, Heriot Watt University.
1 Discretization of Fluid Models (Navier Stokes) Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal.
1 Discretization Methods Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Scientific Computing Introduction to Matlab Programming.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 9.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.
ENG College of Engineering Engineering Education Innovation Center 1 MATLAB – Functions 1 Topics Covered: 1.Functions 2.Function files Functions.
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.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Scalar Conservation Law Dr. Farzad Ismail School of Aerospace and Mechanical Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week.
SCRIPTS AND FUNCTIONS DAVID COOPER SUMMER Extensions MATLAB has two main extension types.m for functions and scripts and.mat for variable save files.
Introduction to Literate Programming in Matlab 2WN50 – Week programming-in-matlab.pptx?dl=0.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
Lecture 12: M/O/F/ for Engineering Applications B Burlingame 27 April 2016.
An Introduction to Programming in Matlab Emily Blumenthal
Beginning Programming for Engineers Animation. Special matrix functions >> clear >> ones(2,3) >> zeros(3,5) >> ones(2) >> zeros(3) >> eye(4) >> magic(4)
EEE 242 Computer Tools for Electrical Engineering
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Tutorial on Matlab Basics
Computer Application in Engineering Design
Lecture 25.
EMT 101 – Engineering Programming
Ch3 Graphics Overview of Plotting Editing Plots
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Communication and Coding Theory Lab(CS491)
Introduction to MATLAB
funCTIONs and Data Import/Export
Matlab Basics Tutorial
Week 7: Computer Tools for Problem Solving and Critical Thinking
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Presentation transcript:

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

2 Extensive Library Package One of the best features in MATLAB is that it has a more extensive library package compared to C++ A MATLAB code can solve almost all types of matrix problems by connecting with LINPACK or EISPACK No need to re-invent the wheel! The next best thing in MATLAB is the library which includes various build-in plotting features

3 2D Plotting Commands use text([X],[Y],’text’) to include text use line([X],[Y]) to draw lines use quiver([X],[Y],[u],[v]) to draw vector lines

4 3D Plotting Commands use plot3([X],[Y],[Z]) to plot points in 3D use surf([X],[Y],[Z]) to draw surface plots can also use mesh([X],[Y],[Z]) (data is in “mesh”) use image([X],[Y],[Z]) to draw surface plots

5 Plot Control Each plot can be customized from the MATLAB script MATLAB uses the concept of “handle” for each element in the figure in the figure a handle is a identification number that points to the properties associated with a figure common commands to use with a “handle”: set,get,gco,gca,gcf

6 Handle Operators set: set the properties associated with the handle get: get all the properties of the figure pointed by the handle handle gco: get all the properties of an object in the figure gca: get all the properties of the axis the figure gcf: returns the handle value

7 Functions in MATLAB Similar to C++, a function is an external piece of code (outside main) which is called by the main program to perform certain tasks. A function has an input and an output Overall use of functions in MATLAB is very similar to C++

8 Function Example Format of a function in MATLAB: function [x1, x2] = functionName(y1,y2) function [x1, x2] = functionName(y1,y2) The function file must be saved as functionName.m variables in [·] (LHS) are outputs of the function variables in (·) (RHS) are inputs of the function

9 Function Example A function to find average value of vector x. function ave = myAverage(x) function ave = myAverage(x) sumx = sum(x); sumx = sum(x); n = length(x); n = length(x); ave = sumx/n; ave = sumx/n; This code must be saved as myAverage.m

10 Tutorial 1 The task is to estimate the area under the sine function u(x) = sin 2πx for x = [0, Pi]. u(x) = sin 2πx for x = [0, Pi]. Estimate the area by dividing x into many intervals. Each interval is an area of a rectangle f (xi)\Delta xi, where \Delta xi = xi − xi−1. Estimate the area by dividing x into many intervals. Each interval is an area of a rectangle f (xi)\Delta xi, where \Delta xi = xi − xi−1. Use a function to denote square area rule and another function to represent trapezoidal rule.

11 function main clc clear all N=input('Enter number of interval:'); lwrlmt=0; uprlmt=pi; dx=(uprlmt-lwrlmt)/N; x= (lwrlmt+dx/2):dx:(uprlmt-dx/2); f=(sin(2*pi*x)); Squarearea=integrate(N,dx,f) Trapezoidalarea=trapezoidal(N,dx,f) end function [r]=integrate(N,dx,f) r=0; for i=1:N r=r+f(i)*dx end function [t]=trapezoidal(N,dx,f) sum=0; for i=2:N-1 sum=sum+f(i); end t=(dx/2)*(f(1)+f(N)+(2*sum)) end Tutorial 1 Solution

12 Exercise 1 Solving the beam problem in Homework 2