LECTURE 1. What Is Matlab? Matlab Windows. Help
|
|
- Brianna Hodges
- 5 years ago
- Views:
Transcription
1 LECTURE 1 What Is Matlab? Matlab ("MATrix LABoratory") is a software package (and accompanying programming language) that simplifies many operations in numerical methods, matrix manipulation/linear algebra, and other tasks engineers will often want to accomplish. The Matlab language shares common ideas (i.e. for loops, if statements) with other languages like Java, C++, and Python. Matlab was chosen for this class because of its use in industry, elaborate Matrix manipulation functionality, tools for efficient graphing/plotting, implementation of numerical algorithms, and specialized toolkits. Matlab Windows When you open Matlab, you see something like this: There are 4 types of windows: Command Window : This is where you type and execute commands Workspace Window: This shows you the current variables Current Directory Window: This shows you the current directory and all the files in that directory. It also allows you to navigate to a different directory. History Window: This shows you previously executed commands Viewing of all these windows can be turned on or off. The most important window is the command window. Help The help functionality within matlab is very well developed. The most important commands to know are the following. You can type these into the command window and press enter: >> help This command shows you all the help topics >> help topic This tells you how the topic is used in matlab. In most cases, it gives you examples as well. Type in: >> help sin This gives you information about how the sine function can be used in matlab. >> helpwin This brings up a window with the help topics. You can conveniently search for topics in this and see examples of usage of different operators and functions.
2 Matlab as a Calculator (Immediate Mode) Let us now type in the following basic math operations: Scalar Variables >> >> >> sin(3) >> clear >> clc From the previous exercise, we can observe that matlab creates a special variable ans every time you type in a command. This special variable stores the answer to the last command. We can access this variable by using its name: >> 3/ >> ans* Some other Special Variables: >> nan NaN >> inf Inf >> pi We can also define variables of our choice and apply operators and functions to these variables:
3 Vectors Matlab can also be used to define and manipulate vectors. Elementwise Definition: Interval Representation: >> x = 5 x = 5 >> y = 10 y = 10 >> x+y 15 >> sin(pi) e-016 >> x = [ ] x = >> x = [1,2,3,4,5] x = >> y = [1;2;3;4;5] y = >> x = 1:5 x = >> y = 100:104 y = >> z = 300:0.1:300.5 >> p = 75:-5:40
4 We can also use mathematical operators to apply to every element on the vector: >> exp(x) >> Z = exp(x-y) Z = 1.0e-042 * >> x.*y We can also apply functions to vectors: Matrices >> a = [1 2 3] >> b = [4 5 6] >> c = cross(a,b) c = >>d = dot(a,b) d = 32 Special matrices >> eye(3) >> magic(3) >> ones(3,4) >> zeros(2,3) >> rand(2,2)
5 Elementwise Matrix Definition >> mat = [1,2,3;4,5,6] mat = Accessing matrix elements >> a = mat(2,2) a = 5 >> mat(1,1) = 0 mat = >> mat(2,3) = -1 mat = Operators: Matrix addition, multiplication, transpose, dotmultiplication, slashes >> a = [1,2;3,4] a = >> b = [5,6;7,8] b = >> a+b >> a-b >> a*b Elementwise functions: Exp, sin >> a.*b >> a/b >> a./b >> a\b
6 Matrix functions >> exp(a) >> sin(a) >> inv(a) >> det(a) -2 >> diag(a) 1 4 Matrix manipulation functions: fliplr, flipud, rot90 >> fliplr(a) >> flipud(a) >> rot90(a) True And False (Relational Operators) In just about all computer languages, you'll run into the concept of TRUE and FALSE. A statement can be True ( i.e. 5 > 3 ), or a statement can be False ( i.e. 5 < 3 ). In Matlab and basically all programming languages: 0 means False and 1 means True.
7 Example: >> 5>3 1 >> 5<3 0 Relational operators are the tests you can use to compare the relationships between two quantities > greater than < less than >= greater than or equal to <= less than or equal to == (2 equals signs!) is equal to ~= NOT equal to IMPORTANT: If you only have a single equal sign, you're not comparing two numbers, you're setting a variable! Therefore, to test (True/False) whether X equals 15, you'd say x==5 Logical Operators Negation Operator: ~ means NOT. This operator switches true and false. >> x = 7 x = 7 >> x > 5 1 >> ~(x > 5) 0 Sometimes, you want to test the truth of two statements at once. You can do this using logical operators. For example, if you want to know if a variable x is between 5 and 10, you would have to test for x > 5 and x < 10. & is used to test if both statements are true is used to test if one of the statements are true >> (x>5)&(x<10) >> (x>5) (x<6)
8 Displaying Results: The semicolon operator In MATLAB, a semicolon at the of the command doesn t display the result on the command window. >> a = 1:5 a = >> a = 1:5; In the rest of our notes, we will use the semicolon. However, if you would like to see the results of the command, do not type the semicolon. Saving and loading workspaces Remember a workspace stores all your current variable names and values associated with them. Saving workspaces is useful when they are result of long computations, so that they can simply be loaded the next time you start matlab. It is also a useful way of sharing data. >> save myworkspace; >> save('myworkspace'); >> save('myworkspace','a') >> load myworkspace >> load('myworkspace') Some Special Commands/Functions >> who >> whos >> which >> what Writing Scripts Scripts are an easy way of running multiple commands. A script file or an m-file is saved with an extension.m. In matlab, navigate to File -> New -> M-file and it opens up the matlab text editor. (or you can also type in edit in the command prompt). The MATLAB text editor is similar to other text editors, but it is especially suited for creating MATLAB-specific files, M- files. There are a number of different features that the MATLAB text editor offer: One features that it offers is syntax highlighting (i.e., comments are green, command lines are black, and other constructs will use other colors), making easier to read the script. Another is that it automatically app the ".m" suffix when saving files, so you don't need to app it yourself. The MATLAB text editor also offers extensive debugging functionality as well (i.e., finding and fixing errors in scripts). Now, to save the last few commands in a file called myscripts.m, you would type:
9 a = 1:5; b = 101:105; c = a+b and then save the file as myscripts.m. Paths Matlab keeps a list of directories in a variable called path. Matlab can only find scripts that are in a directory in the path OR in the current directory. To see the list of directories in its path, type in : >> path; If you want to run myscript.m which you have created in the previous section, make sure that either you have saved the script in the current directory, or add the directory that contains myscript.m to your path. To add this directory to your path, navigate to: File -> Set Path Click on Add Folder and select the folder that contains your script. Now, all you have to do to run your script is to type in the following in the command window: >> myscript NOTE : THIS IS VERY IMPORTANT. If you have saved your script and run into the following error, then the first thing you should do is to check your path. >> myscript??? Undefined function or variable 'myscript'. EXERCISES: 1. Define a random vector a of size Use the mean and median function to find the mean and median 3. Use the sort function to sort values in the vector in ascing order. 4. Use the following functions to find the : Minimum value min Maximum value - max Standard Deviation std Sum sum Built In functions: mean, median, sort, min, max, std, var, abs, sum, floor, ceil, round, rem, sign, complex numbers: imag, real, angle IS s: isnan, isreal, ininf, isempty, isequal
10 Problem Statement For the rest of this class, we will think about writing a program to solve the following problem using different methods: There are 5 passengers sitting in a bus. They have the following ages: 7, 33, 65, 2,16. Write a program that tells you which passengers are children and which ones are adults, given that anyone less than the age of 12 is a child. Input: We will first define a vector variable called ages to hold all the values. ages = [7, 33, 65, 2, 16] Expected output: What we would like to produce is an output which is a vector which has 1 s if the age is a child s age and a 0 if the age is an adult s age: output = [1,0,0,1,0] Conditional Statements A very important part of computer programming is the ability to make decisions based on whether things are True or False. To do this, you'll use "If Statements," which are a crucial piece in just about every programming language. If statements In Matlab, If Statements are implemented as follows: if(condition) statements Example: Write a script that asks for your age and displays You are not a child if you are older than 12 yrs. age = input( How old are you? ); if(age>12) disp('you are not a child'); If- statements Sometimes, you'll want to take one action if the condition is true and a different action if the condition is false. Matlab lets you use If-Else Statements to say "If the condition is true, let's only do the other set of actions; however, if the condition is false, let's only execute the second set of actions."
11 if(condition) statements statements Example: Write a script that asks for your age and displays You are a child if you are less than or equal to 12 yrs and You are not a child if you are older than 12 yrs. age = input( How old are you? ); if(age>12) disp('you are not a child'); disp('you are a child'); If-if- statements Sometimes, you'll want your program to choose one from several courses of action. In these instances, use If-Elseif-Else statements. if(condition) statements if (condition) statements statements Example: Write a script that asks for your age and displays You are a child if you are less than or equal to 12 yrs, You are a teenager if you are between 12 and 19 and You are an adult otherwise. age = input('how old are you: '); if(age>19) disp('you are an adult.'); if(age>12) disp('you are a teenager.'); disp('you are a child.');
12 Solving the bus problem ages = input('please enter the ages of passengers in the bus: '); if ages(1) < 12 output(1) = 1; if ages(2) < 12 output(2) = 1; if ages(4) < 12 output(4) = 1; if ages(5) < 12 output(5) = 1; disp(output) if ages(3) < 12 Switch output(3) Case statements = 1; These are useful for writing cleaner code where the condition you are checking for is equality. If (a==1) disp('one'); if (a==2) (a == 22) (a == 222) disp('two'); if (a==3) (a == 33) disp('three'); disp('something '); versus: switch a case 1 disp('one'); case {2,22,222} disp('two'); case {3,33} disp('three'); otherwise disp('something '); This is also very useful for comparing strings. You do not need to use the strcmp function: switch a case 'One' disp('this is One'); case {'Two','Twenty-Two'} disp('this is Two'); case {'Three', 'Thirty Three'} disp('this is Three'); otherwise disp('something ');
13 Functions Functions are useful for modular processing, ie: where a set of lines of code conduct a task that can be defined using a higher level idea. A function typically takes in a set of inputs and returns a set of outputs. (In some cases it may not take in an input, for example a function that returns the current time.) In matlab a function can be written as : function [output1, output2...] = function_name (input1, input2 ) statements Functions in MATlab can be saved as M-files with the name of the function, function_name.m. The function can then be called by scripts and other functions by passing inputs and receiving outputs as follows: [outputs] = function_name(inputs) Function Workspaces Workspaces contain variables that can be accessed by the program. We have seen the MATLAB workspace and we have learned that we can access variables in the matlab workspace from the command line and a script. When you define a function however, you define a new workspace. This is called the function workspace. The only variables that can be accessed in this workspace are variables that are input to the function or variables that are created in the function. If you would like for a variable that is created or modified in your function to be accessed outside your function, you will have to return it as an output. Every time a function is called, this workspace is generated and when the function has terminated its execution, the workspace is deleted from memory. This separation of workspaces is useful because it allows you to rename variables within functions and also get rid of intermediate variables from the memory once the function has finished its execution. Example Function with one input and no output. Write a function called plusone that takes in a number, adds one to it and then displays it. (save this as plusone.m) function plusone(num) result = num+1; disp(result); Function with one input and one output. Write a function called plustwo that takes in a number, adds two to it, displays the result and then returns the result. (save this as plustwo.m) function result = plustwo(num) result = num+2; disp(result);
14 Function with many inputs and many outputs. Write a function called plusany that takes in two numbers, adds them, displays the result and then returns the sum value and the mean value. (save this as plusany.m) function [sumvalue, meanvalue] = plusany(num1, num2) sumvalue = num1+num2; meanvalue = sumvalue / 2; disp(sumvalue); disp(meanvalue); Special Variables Nargin number of input arguments used to call the function Nargout number of output arguments used to call the function Return The return command causes a return to the invoking function. What this means is that it stops execution of the function after this line and the value of the output variables that the function outputs will be what it is as that line. For example, if we modify the above function to: function [sumvalue, meanvalue] = plusany(num1, num2) sumvalue = 0; meanvalue = 0; sumvalue = num1+num2; if sumvalue < 0 return meanvalue = sumvalue / 2; disp(sumvalue); disp(meanvalue) Normally functions return when the of the function is reached. Exercise: Write a function called isodd that takes in a number and returns the character O if the value is odd and E if the value is even. (hint: use the rem function). Call this function from the command line script with different values. Solving the bus problem categorize_age.m function category = categorize_age(age) if age < 12 category = 1; category = 0;
15 myscript.m ages = input('please enter the ages of passengers in the bus: '); output(1) = categorize_age(ages(1)); output(2) = categorize_age(ages(2)); output(3) = categorize_age(ages(3)); output(4) = categorize_age(ages(4)); output(5) = categorize_age(ages(5)); Loops disp(output) In programming, loops are used to provide a more efficient way of processing through indexed data or for repeatedly executing a sequence of statements until a certain condition is reached. For loops For loops provide a nice way of processing through indexed data such as vectors. The syntax is as follows: for index = first : last Statements For example, if we have a vector and we would like to display all the elements in the vector: vector = [ ]; for i = 1:length(vector) disp(vector(i)); Note: Try to avoid overwriting your index variable. While loops While loops are used to test for conditions and execute code until a condition is satisfied. The syntax is as follows: while (conditional statement) statements Example: Take in an input value. If the value is less than 100, add 10 to it. Stop only when the value is greater than or equal to 100. number = input( Please input a value: ) while (number < 100) number = number + 10
16 Break This allows you to leave the loop and not execute the statements after the break statement. Continue The continue statement causes the program to return back to the beginning of the loop it is presently in, and to recheck the condition to see if it should continue executing loop code or not. The code in the loop after the "continue" statement is not executed in the same pass. Solving the bus problem myscript.m ages = input('please enter the ages of passengers in the bus: '); for i = 1:5 output(i) = categorize_age(ages(i)); disp(output) Doing it all in one line All in one line Matlab is specially designed to handle matrices efficiently: Exercises output = ages < 12 1) Write a function called 'operate' which takes in two numeric inputs and one character input which is an operator ( '+' or '-') and returns the sum of the two numbers if the character input was '+' and the difference if the character input was '-'. Use a Switch case statement. 2) Write a function called 'add' which takes in either one, or two numeric inputs. If there is only one input, add 2 to the number and return this value. If there are two inputs, add them together and return the value.
17 Script files: myscript.m categorize_age.m ages = input('please enter the ages of passengers in the bus: '); function category = categorize_age(age) %part 1: if statements if ages(1) < 12 output(1) = 1; if age < 12 category = 1; category = 0; if ages(2) < 12 output(2) = 1; if ages(3) < 12 output(3) = 1; if ages(4) < 12 output(4) = 1; if ages(5) < 12 output(5) = 1; disp(output) %part 2: functions output(1) = categorize_age(ages(1)); output(2) = categorize_age(ages(2)); output(3) = categorize_age(ages(3)); output(4) = categorize_age(ages(4)); output(5) = categorize_age(ages(5)); disp(output) % part 3: loops for i = 1:5 output(i) = categorize_age(ages(i)); disp(output)
MATLAB Introductory Course Computer Exercise Session
MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within
More informationMATLAB TUTORIAL WORKSHEET
MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent
More informationConstraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial
1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the
More informationIntroduction to MATLAB. Simon O Keefe Non-Standard Computation Group
Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced
More informationIntroduction to Matlab
Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing
More informationIntroduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices
Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are
More informationLecture 2: Variables, Vectors and Matrices in MATLAB
Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables
More informationMcTutorial: A MATLAB Tutorial
McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB
More informationMATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY
MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up More on Scripts and Functions Basic Programming Lecture 2 Lecture 3 Lecture 4 Wrap Up Last time Loading data from file: load( filename ) Graphical input and
More informationIntroduction to Octave/Matlab. Deployment of Telecommunication Infrastructures
Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,
More informationIntroduction to Matlab
Introduction to Matlab Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 9 January 08 Introduction MATLAB is a programming language that grew out of the need to process matrices. It is used extensively
More informationMATLAB: The Basics. Dmitry Adamskiy 9 November 2011
MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing
More informationIntroduction to Engineering gii
25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.
More informationOutline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 10 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More informationLecturer: Keyvan Dehmamy
MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationINTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX
INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar
More informationChapter 1 Introduction to MATLAB
Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,
More informationMATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)
Digital Signal Processing Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org http://www.yildiz.edu.tr/~naydin Course Details Course Code : 0113620 Course Name: Digital Signal Processing (Sayısal
More informationMatlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia
Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics
More informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More informationIntroduction to Scientific Computing with Matlab
UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents
More informationTeaching Manual Math 2131
Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationLab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013
Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.
More informationMATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras
MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras Module No. #01 Lecture No. #1.1 Introduction to MATLAB programming
More informationVariables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:
Contents VARIABLES... 1 Storing Numerical Data... 2 Limits on Numerical Data... 6 Storing Character Strings... 8 Logical Variables... 9 MATLAB S BUILT-IN VARIABLES AND FUNCTIONS... 9 GETTING HELP IN MATLAB...
More information1 Introduction to Matlab
1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,
More informationMatlab and Psychophysics Toolbox Seminar Part 1. Introduction to Matlab
Keith Schneider, 20 July 2006 Matlab and Psychophysics Toolbox Seminar Part 1. Introduction to Matlab Variables Scalars >> 1 1 Row vector >> [1 2 3 4 5 6] 1 2 3 4 5 6 >> [1,2,3,4,5,6] Column vector 1 2
More informationMATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.
MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,
More informationWhy use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)
MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image
More informationMATLAB Project: Getting Started with MATLAB
Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos, sin,
More informationIntroduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis
Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise
More informationIntroduction to MATLAB Programming
Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationIntroduction to MATLAB
Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse
More informationMATLAB Project: Getting Started with MATLAB
Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,
More informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationMatlab Tutorial, CDS
29 September 2006 Arrays Built-in variables Outline Operations Linear algebra Polynomials Scripts and data management Help: command window Elisa (see Franco next slide), Matlab Tutorial, i.e. >> CDS110-101
More informationIntroduction to MATLAB
ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG
More informationWhat is MATLAB and howtostart it up?
MAT rix LABoratory What is MATLAB and howtostart it up? Object-oriented high-level interactive software package for scientific and engineering numerical computations Enables easy manipulation of matrix
More informationPhysics 326 Matlab Primer. A Matlab Primer. See the file basics.m, which contains much of the following.
A Matlab Primer Here is how the Matlab workspace looks on my laptop, which is running Windows Vista. Note the presence of the Command Window in the center of the display. You ll want to create a folder
More informationFinding, Starting and Using Matlab
Variables and Arrays Finding, Starting and Using Matlab CSC March 6 &, 9 Array: A collection of data values organized into rows and columns, and known by a single name. arr(,) Row Row Row Row 4 Col Col
More informationLecture 1: Hello, MATLAB!
Lecture 1: Hello, MATLAB! Math 98, Spring 2018 Math 98, Spring 2018 Lecture 1: Hello, MATLAB! 1 / 21 Syllabus Instructor: Eric Hallman Class Website: https://math.berkeley.edu/~ehallman/98-fa18/ Login:!cmfmath98
More information1. Register an account on: using your Oxford address
1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation
More informationIntroduction to Matlab. By: Dr. Maher O. EL-Ghossain
Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control
More informationIntroduction to MATLAB
to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays
More informationfunction [s p] = sumprod (f, g)
Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationDr. Nahid Sanzida b e. uet .ac.
ChE 208 Lecture # 5_2 MATLAB Basics Dr. Nahid Sanzida nahidsanzida@che.buet.ac.bd h bd Most of the slides in this part contains practice problems. Students are strongly gyadvised to practise all the examples
More informationComputational Mathematics
Computational Mathematics Hilary Term Lecture 1: Programming Andrew Thompson Outline for Today: Schedule this term Review Introduction to programming Examples Arrays: the foundation of MATLAB Basics MATLAB
More informationUniversity of Alberta
A Brief Introduction to MATLAB University of Alberta M.G. Lipsett 2008 MATLAB is an interactive program for numerical computation and data visualization, used extensively by engineers for analysis of systems.
More informationAMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA
AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical
More informationGetting started with MATLAB
Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline
More informationFall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB
Fall 2014 MAT 375 Numerical Methods Introduction to Programming using MATLAB Some useful links 1 The MOST useful link: www.google.com 2 MathWorks Webcite: www.mathworks.com/help/matlab/ 3 Wikibooks on
More informationCourse Layout. Go to https://www.license.boun.edu.tr, follow instr. Accessible within campus (only for the first download)
Course Layout Lectures 1: Variables, Scripts and Operations 2: Visualization and Programming 3: Solving Equations, Fitting 4: Images, Animations, Advanced Methods 5: Optional: Symbolic Math, Simulink Course
More informationIntroduction to Matlab
Introduction to Matlab Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User
More information1 Overview of the standard Matlab syntax
1 Overview of the standard Matlab syntax Matlab is based on computations with matrices. All variables are matrices. Matrices are indexed from 1 (and NOT from 0 as in C!). Avoid using variable names i and
More informationMathematical Operations with Arrays and Matrices
Mathematical Operations with Arrays and Matrices Array Operators (element-by-element) (important) + Addition A+B adds B and A - Subtraction A-B subtracts B from A.* Element-wise multiplication.^ Element-wise
More informationIntroduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003
Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)
More informationMAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB
MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief
More informationLabVIEW MathScript Quick Reference
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics LabVIEW MathScript Quick Reference Hans-Petter Halvorsen, 2012.06.14 Faculty of Technology, Postboks
More informationMAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB
MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types
More informationSECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing
SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language
More informationOUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.
1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN
More informationMBI REU Matlab Tutorial
MBI REU Matlab Tutorial Lecturer: Reginald L. McGee II, Ph.D. June 8, 2017 MATLAB MATrix LABoratory MATLAB is a tool for numerical computation and visualization which allows Real & Complex Arithmetics
More informationMATLAB Functions and Graphics
Functions and Graphics We continue our brief overview of by looking at some other areas: Functions: built-in and user defined Using M-files to store and execute statements and functions A brief overview
More informationStokes Modelling Workshop
Stokes Modelling Workshop 14/06/2016 Introduction to Matlab www.maths.nuigalway.ie/modellingworkshop16/files 14/06/2016 Stokes Modelling Workshop Introduction to Matlab 1 / 16 Matlab As part of this crash
More informationIntroduction to MATLAB
Introduction to MATLAB --------------------------------------------------------------------------------- Getting MATLAB to Run Programming The Command Prompt Simple Expressions Variables Referencing Matrix
More information1 Built-In Math Functions
14:440:127 Introduction to Computers for Engineers Notes for Lecture 02 Rutgers University, Spring 2010 Instructor- Blase E. Ur 1 Built-In Math Functions Matlab includes many built-in functions for math
More informationMATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks
MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student
More informationMatlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:
1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write
More informationPart #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr
A0B17MTB Matlab Part #1 Miloslav Čapek miloslav.capek@fel.cvut.cz Filip Kozák, Viktor Adler, Pavel Valtr Department of Electromagnetic Field B2-626, Prague You will learn Scalars, vectors, matrices (class
More informationIntroduction to MATLAB
Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how
More informationA 30 Minute Introduction to Octave ENGR Engineering Mathematics Tony Richardson
A 30 Minute Introduction to Octave ENGR 390 - Engineering Mathematics Tony Richardson Introduction This is a brief introduction to Octave. It covers several topics related to both the statistics and linear
More informationIntroduction to MATLAB
Quick Start Tutorial Introduction to MATLAB Hans-Petter Halvorsen, M.Sc. What is MATLAB? MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is
More informationLab 1 Intro to MATLAB and FreeMat
Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical
More informationWhat We Will Learn Today
Lecture Notes 11-19-09 ENGR 0011 - Dr. Lund What we ve learned so far About the MATLAB environment Command Window Workspace Window Current Directory Window History Window How to enter calculations (and
More informationChapter 3. built in functions help feature elementary math functions data analysis functions random number functions computational limits
Chapter 3 built in functions help feature elementary math functions data analysis functions random number functions computational limits I have used resources for instructors, available from the publisher
More informationEL2310 Scientific Programming
Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last
More informationFlow Control and Functions
Flow Control and Functions Script files If's and For's Basics of writing functions Checking input arguments Variable input arguments Output arguments Documenting functions Profiling and Debugging Introduction
More informationAn Introduction to MATLAB. Lab tutor : Dennis Yang LIU Lab 1: Sept. 11, 2014
Lab 1 of COMP 319 An Introduction to MATLAB Lab tutor : Dennis Yang LIU Email: csygliu@comp.polyu.edu.hk Lab 1: Sept. 11, 2014 1 Outline of Lab 1 Introduction to the Lab Matlab overview Basic manipulation
More informationMatlab course at. P. Ciuciu 1,2. 1: CEA/NeuroSpin/LNAO 2: IFR49
Matlab course at NeuroSpin P. Ciuciu 1,2 philippe.ciuciu@cea.fr www.lnao.fr 1: CEA/NeuroSpin/LNAO 2: IFR49 Feb 26, 2009 Outline 2/9 Lesson0: Getting started: environment,.m and.mat files Lesson I: Scalar,
More informationA QUICK INTRODUCTION TO MATLAB
A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally
More informationMatlab Introduction. Scalar Variables and Arithmetic Operators
Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced
More informationAN INTRODUCTION TO MATLAB
AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,
More informationVariable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.
MATLAB Introduction Accessing Matlab... Matlab Interface... The Basics... 2 Variable Definition and Statement Suppression... 2 Keyboard Shortcuts... More Common Functions... 4 Vectors and Matrices... 4
More informationMATLAB BASICS. M Files. Objectives
Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference
More informationCS 221 Lecture. Tuesday, 13 September 2011
CS 221 Lecture Tuesday, 13 September 2011 Today s Agenda 1. Announcements 2. Boolean Expressions and logic 3. MATLAB Fundamentals 1. Announcements First in-class quiz: Tuesday 4 October Lab quiz: Thursday
More informationChapter 1 MATLAB Preliminaries
Chapter 1 MATLAB Preliminaries 1.1 INTRODUCTION MATLAB (Matrix Laboratory) is a high-level technical computing environment developed by The Mathworks, Inc. for mathematical, scientific, and engineering
More informationIntroduction to Matlab
Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.
More informationA QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started
A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered
More informationA = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as
1 Matlab Primer The purpose of these notes is a step-by-step guide to solving simple optimization and root-finding problems in Matlab To begin, the basic object in Matlab is an array; in two dimensions,
More informationWhat is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment
What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful
More information1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 169 / 221
1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 169 / 221 Functions Recall that an algorithm is a feasible solution to the specific problem. 1 A function is a piece of computer code that accepts
More informationSECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB
SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The
More information