Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your.

Slides:



Advertisements
Similar presentations
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Advertisements

MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MATLAB GRAPHICS 2-D.
Chapter 2: Algorithm Discovery and Design
Lecture 3 Creating M-files Programming tools: Input/output(assign/graph-&-display) Repetition (for) Decision (if) © 2007 Daniel Valentine. All rights reserved.
Chapter 2: Algorithm Discovery and Design
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Digital Image Processing Lecture3: Introduction to MATLAB.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
Visual Basic Chapter 1 Mr. Wangler.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
1 Chapter 1 MATLAB Primer This introductory chapter is relatively short and has as its main objective the introduction of MATLAB ® to the reader. This.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
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.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
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.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
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.
Matlab Programming for Engineers Dr. Nidal Farhat Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
© 2001 Business & Information Systems 2/e1 Chapter 8 Personal Productivity and Problem Solving.
Lead Black Slide Powered by DeSiaMore1. 2 Chapter 8 Personal Productivity and Problem Solving.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Recap Function M-files Syntax of Function M-Files Comments Multiple Input and Output Functions.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
Introduction to MATLAB
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
2D Plots 2 ENGR 1181 MATLAB 13. Plotting in the Real World 2D plots generated by MATLAB can be used in a variety of fields, including the one shown here,
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.
MA/CS 375 Fall 2003 Lecture 3. .* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 2 Friday 07 Nov 2014 EGR 115 Introduction to Computing for Engineers.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
EEE 242 Computer Tools for Electrical Engineering
Computer Application in Engineering Design
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Software for scientific calculations
Ch3 Graphics Overview of Plotting Editing Plots
Introduction to MATLAB
User Defined Functions
Plotting Multiple Graphs In The Same Plot
Digital Image Processing
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Plotting Signals in MATLAB
Presentation transcript:

Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your version of MATLAB e.g. SIMULINK, the Symbolic toolbox, and the Controls toolbox This is a big advantage of MATLAB (and tools like this software); it allows you to customize your working environment to meet your own needs. It is not only the ‘mathematics handbook’ of today’s student, engineer and scientist, it is also a useful environment to develop software tools that go beyond any handbook to help you to solve relatively complicated mathematical problems. Your ability to use the complete power of MATLAB is limited only by your experience and educational background. In the first part, we shall discuss the design process and later examine additional examples of the structure plan, which is the detailed description of the algorithm to be implemented

Computer program design process The designs of useful utilities translated into the MATLAB language (either sequences of command lines or functions, which are described later in the text) and saved as M-files in your work directory are the primary and most useful goals of users of tools like MATLAB. There are numerous toolbox in MATLAB but It will be helpful for you to search the MathWorks web site for the variety of products available to help the engineer, scientist and technical manager; it is located on the network at Conditions of computer program design For programs to work well they must satisfy the requirements associated with the problem or class of problems it is intended to solve. method of processing and condition Input

Design process outlines The steps as follows: 1 Problem analysis -The context of the proposed investigation must be established to provide the proper motivation for the design of a computer program. 2 Problem statement - Develop a detailed statement of the mathematical problem to be solved with a computer program. 3 Processing scheme - Define the inputs required and the outputs to be produced by the program. 4 Algorithm -Design the step-by-step procedure using the top-down design process that decomposes the overall problem into subordinate problems 5 Program algorithm - Translate or convert the algorithm into a computer language and debug the syntax errors until the tool executes 6 Evaluation -Test all of the options and conduct a validation study of the computer program (compare similar task) 7 Application - Solve the problems the program was designed to solve.

Example of a structure program (MATLAB) F = input(’Temperature in degrees F:’) C = (F-32)*5/9; disp([’Temperature in degrees C = ’,num2str(C)]) % STOP Note: Define your variable F 1. >> F= [212, 300, 350] F = >> C = (F-32)*5/9; >> disp(['Temperature in degrees C = ',num2str(C)]) Temperature in degrees C =

>> x = -1:0.001:1; % Compute the arc-functions: y1 = acos(x); y2 = asin(x); y3 = atan(x); % Convert the angles from radians to degrees: y1 = 180*y1/pi; y2 = 180*y2/pi; y3 = 180*y3/pi; %Plot the results: plot(y1,x,y2,x,y3,x),grid,legend(’asin(x)’, ’acos(x)’, ’atan(x)’) xlabel(’\theta in degrees’),ylabel(’x, the argument of the function’) % % REMARKS: Note the following: % (1) The acos(x) varies from 0 to 90 to 180 degrees. % (2) The asin(x) varies from -90 to 0 to 90 degrees. % (3) The atan(x) varies from -45 to 0 to 45 degrees. % % Stop Example 2

Graphical users interface design environments' - GUIDE Basic 2-D graphs Graphic (in 2-D) are drawn with the plot statement. In its simplest form, it takes a single vector argument. as in plot(y) e.g. plot(rand(1, 40)). Note: If y is a matrix, its columns are plotted against element indexes. Axes are automatically scaled and drawn to include the minimum and maximum data points The most common form of plot is plot(x, y) where x and y are vectors of the same length Example: x = 0:pi/40:4*pi; plot(x, sin(x))

Straight-line graphs are drawn by giving the x and y coordinates of the end-points in two vectors. Example To draw a line between the point with Cartesian coordinates (0, 1) and (4, 3) use the statement plot([0 4], [1 3]) MATLAB has a set of ‘easy-to-use’ plotting commands, all starting with the string ‘ez’. The easy-to-use form of plot is ezplot. Example ezplot(’sin(x)’)

Multiple plots on the same axes There are at least three ways of drawing multiple plots on the same set of axes (which may however be rescaled if the new data falls outside the range of the previous data). 1.The easiest way is simply to use hold to keep the current plot on the axes. All subsequent plots are added to the axes until hold is released, either with hold off, or just hold, which toggles the hold state. 2.The second way is to use plot with multiple arguments, e.g. plot(x1, y1, x2, y2, x3, y3,... ). Example: plot([0 4], [1 3], [2 5], [0 -2]) OR plotyy(x,sin(x), x, 10*cos(x)) 3.The third way is to use the form, example: plot(x, y)

Multiple plots in a figure: subplot One can show a number of plots in the same figure window with the subplot function. The statement subplot(m, n, p). subplot(2,2,1) mesh(z),title('subplot(2,2,1)') subplot(2,2,2) mesh(z) view(-37.5,70),title('subplot(2,2,2)') subplot(2,2,3) mesh(z) view(37.5,-10),title('subplot(2,2,3)') subplot(2,2,4) mesh(z) view(0,0),title('subplot(2,2,4)') x = 0:pi/40:2*pi; polar(x, sin(2*x)),grid Example 2

3-D plots The function plot3 is the 3-D version of plot. The command plot3 (x, y, z). The projection of a line in 3-D through the points whose coordinates are the elements of the vectors x, y and z. e.g. plot3(rand(1,10), rand(1,10), rand(1,10)) Example 1. Mesh surface [x y ] = meshgrid(-8 : 0.5 : 8); r = sqrt(x.^2 + y.^2) + eps; z = sin(r)./ r; [x y] = meshgrid(0:5); z = x.^2 - y.^2; >> mesh(z) 2. Mesh surface [x y ] = meshgrid(0 : 0.25 : 5); >> r = sqrt(x.^2 + y.^2) + eps; >> z = sin(r)./ r; >> [x y ] = meshgrid(0 : 5); >> mesh (z) 3. Contour plots [x y] = meshgrid(-2:.2:2); >> z = x.* exp(-x.^2 - y.^2); >> meshc(z) [x,y] = meshgrid (-2*pi:0.1:2*pi); z = cos(x).*sin(y); mesh(x,y,z),xlabel('x'),ylabel('y'),zlabel('z') 4. Multiple distributions