Turn on MATLAB - Computational Methods - Lecture Slides, Slides of Calculus for Engineers

These are the Lecture Slides of Computational Methods which includes Thévenin’s Equivalent Circuit, Circuit Simplification, Analysis of Power Transfer, Voltage Division, Analytical Game Plan, Array Operation, Element Operations, Number of Allowable Values etc.Key important points are: Turn on Matlab, Conditional Statements, Systems of Linear Equations, Method of Nodal Analysis, Electrical Potential, Left Division Syntax, Matlab Commands, Interactive Mode, Command Window, Nonexecutable Statement

Typology: Slides

2012/2013

Uploaded on 03/26/2013

abduu
abduu 🇮🇳

4.4

(49)

195 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Learning Goals
Turn On MATLAB and use as a calculator
Create Basic Cartesian Plots
Write and Save simple “Script” Program-
files
Execute Conditional Statements
IF, THEN, ELSE, >, <, >=, etc.
Execute Loop Statements
FOR & WHILE
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Turn on MATLAB - Computational Methods - Lecture Slides and more Slides Calculus for Engineers in PDF only on Docsity!

Learning Goals

  • Turn On MATLAB and use as a calculator
  • Create Basic Cartesian Plots
  • Write and Save simple “Script” Program-

files

  • Execute Conditional Statements
    • IF, THEN, ELSE, >, <, >=, etc.
  • Execute Loop Statements
    • FOR & WHILE

Systems of Linear Equations

  • Consider an Electrical Circuit for Which we need to Find the OutPut Electrical Potential

Ix

1 kΩ

1 kΩ^ 1 kΩ

12 V 1 kΩ

2k Ix

Vo

V 1 V 2

Ix

1 kΩ

1 kΩ^ 1 kΩ

12 V 1 kΩ

2k Ix

Vo

V 1 V 2

 Using the ENGR Method of Nodal Analysis we find

0 1 0 0 12 V

1 2

1 2

1 2

1 2

o x

o x

o x

o x

V V V I

V V V I

V V V I

V V V I

 MTH6 Provides Methods to solve this System of Eqns

Systems of Linear Equations cont

  • Use MATLAB to Solve 4Eqns in 4Unkowns >> A = [1,0,-1,-2000; 0,1,0,0; 1,-1,1,0; 0,0,1,-1000]; >> b = [0;12;0;0]; >> Soln = A\b Soln = **9.

0.**

Row Separator Left Division  Thus the Solution by MATLAB

  1. 003 Amps

3 Volts

12 Volts

9 Volts

2

1

x

o

I

V

V

V

Left Division Syntax

  • “Normal”; i.e., RIGHT Division:

P/Q

  • Read as “ P divided by Q

 LEFT (a.k.a. “Back”), RIGHT Division:

S\R

  • Read as “ R divided by S

READ

READ

Performing MATLAB Ops

  • You can perform operations in MATLAB in two ways:
  1. In the interactive mode, in which all commands are entered directly in the Command window
  2. By running a MATLAB program stored in script “m” file.
  • A Script file contains MATLAB commands, so running it is equivalent to typing all the commands - one at a time - at the Command window prompt.
  • Run the file by typing its name at the Command window prompt

% Comments

  • COMMENTS are NONexecutable Statements that help Document or Explain Script Files
  • The comment symbol (%) may be put anywhere in the line. MATLAB ignores everything to the right of the % symbol.

>>% This is a comment.

>>x = 2+3 % So is this.

x =

5

 Note that the portion of the line before the % sign is executed to compute x.

Script File Usage

  • The name of a script file must begin with a letter , and may include digits and the underscore character, up to 63 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

DeBugging Script Files

  • Program errors usually fall into one of the following categories. 1. Syntax errors such as omitting a parenthesis or comma, or spelling a command name incorrectly. MATLAB usually detects the more obvious errors and displays a message describing the error and its location.
  1. Errors due to an incorrect mathematical procedure are called runtime errors. Their occurrence often depends on the particular input data.
  • A common example is division by zero

Programming Style

1. Comments section

a. The nam e of the program and any key words in the first line. b. The date created, and the creators' names 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 (file)name of every user-defined function called by the program.

Programming Style cont

  1. Input section
    • Include input data and/or the input functions and comments for documentation.
  2. Calculation section
  3. Output section
    • This section might contain functions for displaying the output on the screen or creating a plot

Script File Example

  • Problem: The speed v of a falling object

dropped with no initial velocity is given as a

function of time t by v = gt.

  • Where g is the Acceleration of Gravity; a CONSTANT = 32.2 ft/s 2
  • Use MATLAB to Plot v as a

function of t for 0 ≤ t ≤ tf

  • Where tf is the final time entered by the user.

FallSpeed Plot for t f = 7 sec

MATLAB Help → Hidden Tab

Command Window Help-Fcns

  • help funcname: Displays in the Command window a description of the specified function funcname.
  • lookfor topic: Displays in the Command window a brief description for all functions whose description includes the specified key word topic.
  • doc funcname: Opens the Help Browser to the reference page for the specified function funcname, providing a description, additional remarks, and examples.