MATLAB AutoCAD Visio Rational Rose Computer Applications in Engineering Design Introductory Lecture LabVIEW PSPICE Orcad.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
2D Plots 1 ENGR 1181 MATLAB 12.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
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.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
For loop Khairul anwar.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers Chapter 5 Advanced.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
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.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Introduction to Matlab and Simulink
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB – 2D Plots 1 Go to the class drive: ---> MatLab - Graphing ---> Seed Files.
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
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.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 2 in MATLAB Topics Covered: 1.More about 2-D plots  Placing multiple.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Computer Application in Engineering Design
Lecture 25.
Lecture 25: Exploring data
Two-Dimensional Plots
MATLAB DENC 2533 ECADD LAB 9.
(Mohammed Sami) Ashhab
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
MATLAB Tutorial Dr. David W. Graham.
MATLAB How to use (using M-files) Double click this icon
MatLab – 2D Plots 2 MATLAB has many built-in functions and commands to create various types of plots. Instructor notes: We start with an example of some.
Plotting Data with MATLAB
Basic Matlab Matrix definition a=[1,2 ; 3,4] => a=
MATLAB How to use (using M-files)
Structures- case, sequence, formula node
Plotting Signals in MATLAB
How to Use MATLAB A Brief Introduction.
Introduction to Matlab
Presentation transcript:

MATLAB AutoCAD Visio Rational Rose Computer Applications in Engineering Design Introductory Lecture LabVIEW PSPICE Orcad

Course Information Nuts and Bolts Course Code:CP-203 Prerequisites: Computer Programming Credit Hours: 2 (Theory) + 1 (Lab) Class Homepage: All handouts, announcements, assignments, etc. posted to website “Lectures” link continuously updates topics, handouts, and reading Class Mailing List: Google / Yahoo Group (Required addresses of all students)

Course Syllabus MATLAB Orcad Visio Pspice AutoCAD Rational Rose LabVIEW UML

Tools Matlab and Orcad is used for electrical/computer systems design AutoCAD like design tools are taught for 3D engineering drawings. Introduction to computer-aided design tools including AutoCAD, OrCAD, MATLAB, LabVIEW, Rational Rose and Visio, etc. Study of theoretical concepts of electronic components and circuits using simulation softwares: PSPICE, MATLAB, and LabVIEW. Tools like Visio and Rational Rose are used for software drawing like process diagrams, class diagram, sequence diagram, interaction diagrams and deployment diagram, Entity-Relationship diagram etc. Design of software designs using Visio and Rational Rose for understanding and implementing object oriented designs and standards like UML.

Introduction to Matlab Click on the Matlab icon/start menu initialises the Matlab environment: The main window is the dynamic command interpreter which allows the user to issue Matlab commands The variable browser shows which variables currently exist in the workspace Variable browser Command window Command history

Matlab Programming Environment Matlab (Matrix Laboratory) is a dynamic, interpreted, environment for matrix/vector analysis Variables are created at run-time, matrices are dynamically re-sized, … User can build programs (in.m files or at command line) using a C/Java-like syntax Ideal environment for model building, system identification and control (both discrete and continuous time Wide variety of libraries (toolboxes) available

Basic Matlab Example a=[1,2,3,4,5]; b=[a;a;a] b= Example a=[1;2;3;4;5]; b=[a,a,a] b= Example (transpose) a=[1;2;3;4;5]; b=a’ b=

Basic Matlab Strings a=[‘a’,’b’,’c’] a= abc b=[a;a;a] b= abc abc Strings a=[‘a’,’b’,’c’] a= abc b=[a,a,a] b= abcabcabc Strings a=[‘a’,’b’,’c’] b=[‘a’,’c’,’c’] c=(a==b); c= 1 0 1

Basic Matlab

A=zeros(a 1, a 2, a 3,… a n ); A is an n dimensional matrix of zeros. A=ones(a 1, a 2, a 3,… a n ); A is an n dimensional matrix of ones. size(A) return the size of A.

Basic Matlab A(m,n) returns the value of the matrix in row-m and column-n. b=A(1:end,1) : b will be equal to column 1 of A b=A(5:10,5:10) : b will a-6x6 matrix containing all values of A from rows 5-10 and columns 5-10.

Basic Matlab Functions in Matlab function [output variables]=function_name (input variables) Input and output variables, can be of any type.

function [out_1,out_2,out_3] = Function_Dec (in_1,in_2,in_3) out_1=in_1+in_2+in_3; out_2=[ 'hello' ; 'world' ]; out_3=[1,2,3,4,5]; return; Basic Matlab Functions in Matlab

input: » [a,b,c]=Function_dec(5,3,2) output: a = 10 b = hello world c = input: » [a,b,c]=Function_dec([1,2,3],[6,5,4],[3,4,5]) output: a = b =hello world c = Basic Matlab Functions in Matlab

Basic Matlab Bit-wise operations Variables must be integers BITAND(a,b) Bit-wise AND. BITOR (a,b)Bit-wise OR. BITXOR (a,b)Bit-wise XOR. BITGET (a,bit-num) Get bit. BITSET (a,bit-num,1/0)Set bit.

Basic Matlab conditions If ( Boolean expression). end; Boolean expression == : Is Equal ~=: Not Equal > : Is grater then < : Is less Then >=: Is grater then or equal to <=: Is less then or equal to

Basic Matlab conditions switch switch_expr case case_expr, statement,..., statement case {case_expr1, case_expr2, case_expr3,...} statement,..., statement... otherwise, statement,..., statement end

Basic Matlab Loops for j=start:step:end. end; example: for j=-1:0.2:3. end; while Boolean expression,. end; example: while a>b,. end; break - Terminate execution of WHILE or FOR loop. break terminates the execution of FOR and WHILE loops. In nested loops, BREAK exits from the innermost loop only.

Topics Covered: 1.Plotting basic 2-D plots. The plot command. The fplot command. Plotting multiple graphs in the same plot. Formatting plots. Two Dimensional Plots

MAKING X-Y PLOTS MATLAB has many functions and commands that can be used to create various types of plots. In our class we will only create two dimensional x – y plots.

Plot title y axis label x axis label Text Tick-mark label EXAMPLE OF A 2-D PLOT Data symbol Legend Tick-mark

TWO-DIMENSIONAL plot() COMMAND where x is a vector (one dimensional array), and y is a vector. Both vectors must have the same number of elements.  The plot command creates a single curve with the x values on the abscissa (horizontal axis) and the y values on the ordinate (vertical axis).  The curve is made from segments of lines that connect the points that are defined by the x and y coordinates of the elements in the two vectors. The basic 2-D plot command is: plot(x,y)

 If data is given, the information is entered as the elements of the vectors x and y.  If the values of y are determined by a function from the values of x, than a vector x is created first, and then the values of y are calculated for each value of x. The spacing (difference) between the elements of x must be such that the plotted curve will show the details of the function. CREATING THE X AND Y VECTORS

PLOT OF GIVEN DATA Given data: >> x=[ ]; >> y=[ ]; >> plot(x,y) A plot can be created by the commands shown below. This can be done in the Command Window, or by writing and then running a script file. Once the plot command is executed, the Figure Window opens with the following plot x y

PLOT OF GIVEN DATA

LINE SPECIFIERS IN THE plot() COMMAND Line specifiers can be added in the plot command to:  Specify the style of the line.  Specify the color of the line.  Specify the type of the markers (if markers are desired). plot(x,y,’line specifiers’)

LINE SPECIFIERS IN THE plot() COMMAND Line SpecifierLineSpecifierMarkerSpecifier StyleColorType Solid - red r plus sign + dotted : green gcircle o dashed -- blue basterisk * dash-dot -.Cyan cpoint. magenta msquare s yellow ydiamond d black k plot(x,y, ‘ line specifiers’)

LINE SPECIFIERS IN THE plot() COMMAND  The specifiers are typed inside the plot() command as strings.  Within the string the specifiers can be typed in any order.  The specifiers are optional. This means that none, one, two, or all the three can be included in a command. EXAMPLES: plot(x,y)A solid blue line connects the points with no markers. plot(x,y,’r’)A solid red line connects the points with no markers. plot(x,y,’--y’)A yellow dashed line connects the points. plot(x,y,’*’)The points are marked with * (no line between the points.) plot(x,y,’g:d’)A green dotted line connects the points which are marked with diamond markers.

Year Sales (M) PLOT OF GIVEN DATA USING LINE SPECIFIERS IN THE plot() COMMAND >> year = [1988:1:1994]; >> sales = [127, 130, 136, 145, 158, 178, 211]; >> plot(year,sales,'--r*') Line Specifiers: dashed red line and asterisk markers.

PLOT OF GIVEN DATA USING LINE SPECIFIERS IN THE plot() COMMAND Dashed red line and asterisk markers.

% A script file that creates a plot of % the function: 3.5^(-0.5x)*cos(6x) x = [-2:0.01:4]; y = 3.5.^(-0.5*x).*cos(6*x); plot(x,y) CREATING A PLOT OF A FUNCTION Consider: A script file for plotting the function is: Creating a vector with spacing of Calculating a value of y for each x. Once the plot command is executed, the Figure Window opens with the following plot

A PLOT OF A FUNCTION

CREATING A PLOT OF A FUNCTION If the vector x is created with large spacing, the graph is not accurate. Below is the previous plot with spacing of x = [-2:0.3:4]; y = 3.5.^(-0.5*x).*cos(6*x); plot(x,y)

THE fplot COMMAND fplot(‘function’,limits) The fplot command can be used to plot a function with the form: y = f(x)  The function is typed in as a string.  The limits is a vector with the domain of x, and optionally with limits of the y axis: [xmin,xmax] or [xmin,xmax,ymin,ymax]  Line specifiers can be added.

PLOT OF A FUNCTION WITH THE fplot() COMMAND >> fplot('x^2 + 4 * sin(2*x) - 1', [-3 3]) A plot of:

PLOTTING MULTIPLE GRAPHS IN THE SAME PLOT Plotting two (or more) graphs in one plot: 1.Using the plot command. 2. Using the hold on, hold off commands

USING THE plot() COMMAND TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT Plots three graphs in the same plot: y versus x, v versus u, and h versus t.  By default, MATLAB makes the curves in different colors.  Additional curves can be added.  The curves can have a specific style by adding specifiers after each pair, for example: plot(x,y,u,v,t,h) plot(x,y,’-b’,u,v,’—r’,t,h,’g:’)

USING THE plot() COMMAND TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT Plot of the function, and its first and second derivatives, for, all in the same plot. x = [-2:0.01:4]; y = 3*x.^3-26*x+6; yd = 9*x.^2-26; ydd = 18*x; plot(x,y,'-b',x,yd,'--r',x,ydd,':k') vector x with the domain of the function. Vector y with the function value at each x. Vector yd with values of the first derivative. Vector ydd with values of the second derivative. Create three graphs, y vs. x (solid blue line), yd vs. x (dashed red line), and ydd vs. x (dotted black line) in the same figure.

USING THE plot() COMMAND TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT

hold on Holds the current plot and all axis properties so that subsequent plot commands add to the existing plot. hold off Returns to the default mode whereby plot commands erase the previous plots and reset all axis properties before drawing new plots. USING THE hold on, hold off, COMMANDS TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT

Plot of the function, and its first and second derivatives, for all in the same plot. x = [-2:0.01:4]; y = 3*x.^3-26*x+6; yd = 9*x.^2-26; ydd = 18*x; plot(x,y,'-b') hold on plot(x,yd,'--r') plot(x,ydd,':k') hold off Two more graphs are created. First graph is created. USING THE hold on, hold off, COMMANDS TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT

Plot title y axis label x axis label Text EXAMPLE OF A FORMATTED 2-D PLOT Data symbol 106 Legend Tick-mark Tick-mark label

FORMATTING PLOTS A plot can be formatted to have a required appearance. With formatting you can:  Add title to the plot.  Add labels to axes.  Change range of the axes.  Add legend.  Add text blocks.  Add grid

FORMATTING PLOTS There are two methods to format a plot: 1.Formatting commands. In this method commands, that make changes or additions to the plot, are entered after the plot() command. This can be done in the Command Window, or as part of a program in a script file. 1.Formatting the plot interactively in the Figure Window. In this method the plot is formatted by clicking on the plot and using the menu to make changes or add details

FORMATTING COMMANDS title(‘string’) Adds the string as a title at the top of the plot. xlabel(‘string’) Adds the string as a label to the x -axis. ylabel(‘string’) Adds the string as a label to the y -axis. axis([xmin xmax ymin ymax]) Sets the minimum and maximum limits of the x - and y -axes.

FORMATTING COMMANDS legend(‘string1’,’string2’,’string3’) Creates a legend using the strings to label various curves (when several curves are in one plot). The location of the legend is specified by the mouse. text(x,y,’string’) Places the string (text) on the plot at coordinate x,y relative to the plot axes. gtext(‘string’) Places the string (text) on the plot. When the command executes the figure window pops and the text location is clicked with the mouse.

EXAMPLE OF A FORMATTED PLOT Below is a script file of the formatted light intensity plot (2 nd slide) x=[10:0.1:22]; y=95000./x.^2; xd=[10:2:22]; yd=[ ]; plot(x,y,'-','LineWidth',1.0) hold on plot(xd,yd,'ro--','linewidth',1.0,'markersize',10) hold off Creating a vector with light intensity from data. Creating a vector with coordinates of data points. Creating vector x for plotting the theoretical curve. Creating vector y for plotting the theoretical curve.

EXAMPLE OF A FORMATTED PLOT Formatting of the light intensity plot (cont.) Creating a legend. xlabel('DISTANCE (cm)') ylabel('INTENSITY (lux)') title('\fontname{Arial}Light Intensity as a Function of Distance','FontSize',14) axis([ ]) text(14,700,'Comparison between theory and experiment.','EdgeColor','r','LineWidth',2) legend('Theory','Experiment',0) Creating text. Title for the plot. Setting limits of the axes. Labels for the axes. The plot that is obtained is shown again in the next slide.

EXAMPLE OF A FORMATTED PLOT

FORMATTING A PLOT IN THE FIGURE WINDOW Once a figure window is open, the figure can be formatted interactively. Use Figure, Axes, and Current Object- Properties in the Edit menu Click here to start the plot edit mode. Use the insert menu to

QUIZ Q1.a=[‘ab’,’ac’,’ad’],b=[a,a,a]B=? Q2. Differentiate hold on and hold off.