Basic operations in Matlab

Slides:



Advertisements
Similar presentations
Basic Elements of C++ Chapter 2.
Advertisements

Digital Image Processing Lecture3: Introduction to MATLAB.
Python Programming Fundamentals
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Copyright © The McGraw-Hill Companies, Inc. Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 1 An Overview of MATLAB.
A Brief introduction to MatLAB ($50 - $99 for students)
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
Introduction to Programming
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Structured Computer Programming EE 201 Introduction to MATLAB 7 for Engineers بسم الله الرحمن الرحيم King Abdulaziz University College of Engineering Dept.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
Introduction to Programming
Chapter 1.2 Introduction to C++ Programming
Introducing Python Introduction to Python.
Development Environment
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Introduction to Programming
Chapter 6 JavaScript: Introduction to Scripting
Release Numbers MATLAB is updated regularly
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Completing the Problem-Solving Process
Chapter 2 - Introduction to C Programming
Appendix B MathScript Basics
Computing Fundamentals
Basic Elements of C++.
Chapter 2 Assignment and Interactive Input
Introduction to MATLAB for Engineers, Third Edition
Objectives Identify the built-in data types in C++
Introduction to Programming
Guide To UNIX Using Linux Third Edition
Chapter 4 MATLAB Programming
Introduction to Matlab
Introduction to Programming
Scripts & Functions Scripts and functions are contained in .m-files
Intro to PHP & Variables
MATLAB DENC 2533 ECADD LAB 9.
User Defined Functions
Basic Elements of C++ Chapter 2.
Lecture 1: Introduction
Chapter 2 Elementary Programming
Introduction to Programming
Use of Mathematics using Technology (Maltlab)
Digital Image Processing
Introduction to Programming
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Using screens and adding two numbers - addda.cbl
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
Introduction to Programming
12th Computer Science – Unit 5
Introduction to Programming
Computer Programming-1 CSC 111
Introduction to C Programming
Starter Which of these inventions is: Used most by people in Britain
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Basic operations in Matlab EE 201

Class Learning Objectives Achieve Comprehension LOL of Matlab basic operations.

Script files You can perform operations in MATLAB in two ways: 1. In the interactive mode (similar to using a calculator), in which all commands are entered directly in the Command window, or 2. By running a MATLAB program stored in script file. This type of file contains MATLAB commands, so running it is equivalent to typing all the commands - one at a time - at the Command window prompt.

Script files A script files contain a sequence of MATLAB commands, and is useful when you need to use many commands or arrays with many elements. Script files in MATLAB allows you to write your own programs and save in M-files, which have the extension .m, for example, name of file.m

Creating M-file From the File menu →select New →Script Then will see a new edit window called editor window as shown in figure

Keep in mind when using script files: The name of a script file MUST begin with a letter, and may include digits and the underscore character, up to 31 characters. Do not give a script file the same name as a variable. Do not give a script file the same name as a MATLAB command or function. You can check to see if a command, function or file name already exists by using the exist command.

COMMENTS The comment symbol (%) may be put anywhere in the line. MATLAB ignores everything to the right of the % symbol. For example :

Programming Style 1.Comments section % a. The name of the program and any key words in the first line. b. The date created, the student‘s names and ID number in the second line. c. The definitions of the variable names for every input and output variable. Include definitions of variables used in the calculations and units of measurement for all input and all output variables! d. The name of every user-defined function called by the program.

Programming Style 2. Input section : Include input data and/or the input functions and comments for documentation. 3. Calculation section 4.Output section This section might contain functions for displaying the output on the screen.

Examples of a Script File Write a MATALB program that inputs three integers from the keyboard and prints the sum,average,and product of these numbers. The screen dialogue should appear as follows: The first integer is : 13 The second integer is :27 The third integer is :14 Sum is: 54 Average is:18 Product is :4914

You can execute a script file by : -Go to Debug menu →Run or -Press F5 -Typing the name of script file without the extension .m at the command window

Example of script file Write a MATLAB program that compute the volume of sphere with a radius 3 cm.

Example of script file Write a MATLAB program that prompts the user to enter a radius (cm) of sphere to compute the volume of sphere.