ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.

Slides:



Advertisements
Similar presentations
StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
Introduction to MATLAB
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB.
Week 7 - Programming I Relational Operators A > B Logical Operators A | B For Loops for n = 1:10 –commands end.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
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.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
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.
Intro to Matlab 1.Using scalar variables 2.Vectors, matrices, and arithmetic 3.Plotting 4.Solving Systems of Equations Can be found at:
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
The MatLab Language Mathematics Laboratory The MathWorks
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
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 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai,
ECE 1304 Introduction to Electrical and Computer Engineering
Control Statements in Matlab
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
INTRODUCTION TO MATLAB
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.
Experiment No. (1) - an introduction to MATLAB
CS 111 Introduction to Computing in Engineering and Science
Matlab Basics.
Computer Simulation Lab
Presentation transcript:

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Learning Objectives Learn how to use Matlab - layout of windows, interpreter, on-line help. Learn the types of programming methods. Learn Matlab language syntax: –variables, –scalars, vectors, matrices –if, for, while statements Learn how to plot graphs.

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory MATLAB MATLAB = MATrix LABoratory. Interactive system and programming language for technical computation. Interpreter - like Basic, not compiler like C, C++, Fortran. Toolboxes - prepared sets of integrated tools for work in a specific area (Controls, PDE’s). We will use it for simple 3D modeling, parametrics, and graphics.

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory User Interface 3 Windows: Command Window - enter Matlab commands, executed immediately by interpreter, answers printed in Window. Graphics Window - displays plots and graphs. Edit Window - prepare scripts and functions. Scripts - collection of commands that the interpreter executes. Function - collection of commands enveloped in a function call.

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory User Interface Command Window Edit Window Graphics Window

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Programming 3 Methods: Type directly into Command Window: try new things, experiment, learn Matlab. Write scripts using Edit Window: save commands to execute at one time. Write functions using Edit Window: save commands encapsulated into reusable fragments (functions). Example: math functions like sin(), cos(), tan()...

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Matlab Language Some similarities to C and Basic. Variables: Scalars, Vectors, Matrices Start with a letter Can contain letters, digits, and underscore Any length, but must be unique within first 19 characters Case-sensitive Examples: engine, Engine, degree2radian, cam_shaft Scalars: x = 2.0; deg2rad = pi/180; Vectors: x = [3.5]; y = [1.5, 3.1]; Matrices: z = [-1, 0, 0; 1, 1, 0; 1, -1, 0; 0, 0, 2];

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Language (2) xy = [x y] yields [3.5, 1.5, 3.1] Accessing vectors and matrices x(1) yields 3.5 z(3,2) yields -1 result = y(2) + z(3,2) yields 2.1 Size of Matrix: size(z) => [4 3] (4 rows, 3 columns) => means ‘yields’ What is ‘;’? It instructs the interpreter to NOT print the result of the computation.

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Language (3) Colon Operator: ‘:’ extracts row or column from matrix. A = z(:,1) extracts first column from z b = z(3:4, 1:2) extracts bottom left 2x2 submatrix. Transpose Operator: ‘ Row vector is not the same as column vector. B = a’ a = 0:4; => a = [ ]

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Language (4) Special Values and Matrices pii,j = sqrt(-1) Inf = infinity NaN = not a number - occurs when dividing by 0 eps = machine epsilon A = zeros(3) B = ones(3) I = eye(4)

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Language (5) Operations: Scalars Matrices Addition++ Subtraction-- Multiplication** element by element.* Division/./ (element by element) Exponentiation ^.^

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Language - Logic and Control If Statement: if logical expression statements … end if g < 50 cnt = cnt + 1; fprintf (1, ‘Count is now %d\n’, cnt); if b > g b = 0; end Else and elseif: if temp > 100 disp(‘Really hot!’); elseif temp > 65 disp(‘Temp OK’); else disp (‘Too cold’); end

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Relational & Logical Operators Relational Operators < less than <= less than or equal > greater than >= greater than or equal == equal ~= not equal Logical Operators ~ not & and | or

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Looping - For For Loops for index = expression statements end expression is initial: increment: limit for theta = 0.0: 2.0: rth = deg2rad * theta; ctheta = cos (rth); stheta = sin (rth); end Replace ‘for’ loop: theta = 0.0: 2.0: rth = theta * deg2rad; ctheta = cos (rth); stheta = sin (rth); Replace ‘for’ loop: theta = 0.0: 2.0: rth = theta * deg2rad; ctheta = cos (rth); stheta = sin (rth);

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Looping - While While Loops Loop continues executing until “expression” evaluates to false. While expression statements … end found_yet = 0; k = 0; while k < 10 & (~found_yet) k = k + 1; end

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Plotting 2D Plots: plot (x,y, ‘abc’) x, y = vectors of #’s to be plotted ‘abc’ = up to 3 characters that control line type, color, and how points are plotted. plot (x,y), title(‘Lab Exp 1’), xlabel(‘Trial’), … ylabel(‘Distance (ft)’), grid; 3D Plots: plot3 (x,y,z, ‘abc’) plot3 (x, y, z, ‘b+-’); plots x, y, z in blue (‘b’), with ‘+’ at the given data points, and using a solid line (‘-’). Rotate3D - command to allow you to rotate the image in the graphics window.

ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Matlab Summary How to use Matlab - layout of windows, interpreter, on-line help. Types of programming methods. Matlab language syntax –variables, –scalars, vectors, matrices –if, for, while statements Plotting