Objective: To be able to create script and function files

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
Al-Amer An Introduction to MATLAB Dr. Samir Al-Amer Term 062.
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.
4. Week 04.March Use of M-File Editor/Debugger: text editor, debugger; editor works with file types in addition to.m (MATLAB “m-files”)
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
GNU/Qt Octave Rohin Kumar Y, Dept. of Physics & Astro Physics, University of Delhi.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 Djordje Gligorijevic, Temple University, Fall 2015.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
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.
1 Functions ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
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.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
Introduction to MATLAB
Scientific Computing Introduction to Matlab Programming.
Introduction to Matlab
CS1109 L AB 3 July 3rd. R OAD M AP Homework submission Review How to use function and scripts While-end Finish last exercise Lab 2 Challenge questions.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Array Operations ENGR 1181 MATLAB 4.
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.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
Introduction to MATLAB ENGR 1181 MATLAB 1. MATLAB Built-in Math Functions  Pre-defined in MATLAB ready for use exp(x) – exponential (e x ) log(x) – natural.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Intro to Matlab Yipei Wang & Qihui Li {yipeiw,
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
1 Matlab for Engineering Applications Introduced by Jen-Yang Chen Department of Electronic Engineering Ming Chuan University.
NoViC, Dept. of Mechanical Eng Acoustics Lab., NoViC 1. Download Matlab 2.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
Goals:  Understand logarithms as the inverse of exponents  Convert between exponential and logarithmic forms  Evaluate logarithmic functions.
Parent Functions. Learning Goal I will be able to recognize parent functions, graphs, and their characteristics.
Introduction to Matlab PHY September Why Matlab? No need to compile code Huge amount of built-in functions Highly optimized and fast, in general.
Today Variable declaration Mathematical Operators Input and Output Lab
CSC 4630 Meeting 7 February 7, 2007.
ECE 1304 Introduction to Electrical and Computer Engineering
Built-in MATLAB Functions Chapter 3
Introduction to Matlab
L – Modeling and Simulating Social Systems with MATLAB
ECE 1304 Introduction to Electrical and Computer Engineering
Logarithmic Functions and Their Graphs
Functions (subprograms)
Introduction to MATLAB
Matlab for Engineering Applications
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
5.4 Logarithmic Functions and Models
CS100J 26 April. Matlab Use help button!!! Variables, values, types
Function Notation “f of x” Input = x Output = f(x) = y.
Introduction to MATLAB
Introduction to Matlab LAB 4
funCTIONs and Data Import/Export
Evaluating Logarithms
CSE 307 Basics of Image Processing
Exponential and Logarithmic Forms
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.
-seminar 1 for digital signal processing
Matlab Basics Tutorial
Review: How do you find the inverse of a function? Application of what you know… What is the inverse of f(x) = 3x? y = 3x x = 3y y = log3x f-1(x) = log3x.
Logarithms.
Introduction to Matlab
CHAPTER 3 Built-in MATLAB Functions
Presentation transcript:

Objective: To be able to create script and function files SE207 Lab 2 Objective: To be able to create script and function files

MATLAB Files Two types of files: Both have the extension .m [ M-files] SCRIPT files FUNCTION files Both have the extension .m [ M-files] (file1.m, f2.m)

M-files t=0:0.1:10 y=sin(t) plot(t,y) function [y]=fplot2(t) y=sin(t) SCRPT Files: a list of MATLAB instructions saved on a file for convenience no input argument The variables are global FUNCTION files Starts with “FUNCTION “ statement that specifies the input and output arguments Local variables Treated as the built-in functions t=0:0.1:10 y=sin(t) plot(t,y) function [y]=fplot2(t) y=sin(t) plot(t,y)

Function M-files function y=fplot(t) y=sin(t); create an m-file and save it as fplot.m FILE New M-file function y=fplot(t) y=sin(t); Open M-file MATLAB Command Window >> t=0:0.1:10 >> z=fplot(t) >> plot(t,z)

MATRIX OPERATIONS Transpose A’ inverse inv(A) determinant det(A) rank rank(A)

Special functions Exponential exp(x) square root sqrt(x) natural logarithm log(x) common logarithm log10(x) absolute value abs(x) more details Use help to know related functions

If structures General form: If condition statements else end If (x>0) f=x^2 else f=0 end

for loops General form: special case for index=initial: limit for index=initial: increment: limit statements end special case if increment is 1 for index=initial: limit for i=1:100 x(i)=sin(i*.2) end