### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# DIFFERENTIAL EQUATIONS MATH 3331

UCA

GPA 3.59

### View Full Document

## 44

## 0

## Popular in Course

## Popular in Mathematics (M)

This 20 page Class Notes was uploaded by Daniela Wilkinson on Thursday October 22, 2015. The Class Notes belongs to MATH 3331 at University of Central Arkansas taught by Wei-Jiu Liu in Fall. Since its upload, it has received 44 views. For similar materials see /class/227197/math-3331-university-of-central-arkansas in Mathematics (M) at University of Central Arkansas.

## Reviews for DIFFERENTIAL EQUATIONS

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/22/15

MATLAB Tuturial 1 MATLAB Desktop 11 Command Window This is the primary place where you interact with MATLAB The prompt gtgt is displayed in this window and when this window is active a blinking cursor appears to right of the prompt This cursor and prompt signify that MATLAB is waiting to perform a mathematical operation In this window you can enter variables and mathematical expressions and run commands and MATLAB codes called M les Practice Enter gtgt 11 and hit the enter key ans 2 gtgtx1 gtgt Z xy gtgt The expression z 1 means that the value 1 is assigned to the variable x Multiple commands are separated by commas or semicolons they can be placed on one line gtgt Commas tell MATLAB to display results semicolons suppress printing 12 Help Browser Use the Help browser to search and view documentation and demos for all your Math Works products The Help browser is a Web browser integrated into the MATLAB desktop that displays HTML documents To open the Help browser7 click the help button in the toolbar7 or type helpbrowser in the Command Window The Help browser consists of two panes7 the Help Navigator7 which you use to nd information7 and the display pane7 where you view the information The following are useful commands for online help 0 help lists topics on which help is available 0 helpwin opens the interactive help window 0 helpdesk opens the web browser based help facility 0 help topic provides help on topic 0 lookfor string lists help topics containing string 13 Editor Debugger Use the EditorDebugger to create and debug M les7 which are programs you write to run MATLAB functions The EditorDebugger provides a graphical user interface for basic text editing7 as well as for M le debugging You can use any text editor to create M les7 such as Emacs7 and can use prefer ences accessible from the desktop File menu to specify that editor as the default If you use another editor7 you can still use the MATLAB EditorDebugger for debug ging7 or you can use debugging functions7 such as dbstop7 which sets a breakpoint If you just need to view the contents of an M le7 you can display it in the Command Window by using the type function 2 Simple Mathematics 21 Variables MATLAB does not require any type declarations or dimension statements When MATLAB encounters a new variable name it automatically creates the variable and allocates the appropriate amount of storage If the variable already exists MATLAB changes its contents and if necessary allocates new storage For example gtgt numOfSudents 25 creates a 1 by 1 matrix named numOfSudents and stores the value 25 in its single element Variable names consist of a letter followed by any number of letters digits or underscores MATLAB uses only the rst 31 characters of a variable name MATLAB is case sensitive it distinguishes between uppercase and lowercase letters A and a are not the same variable To view the matrix assigned to any variable simply enter the variable name Variable names can contain up to 63 characters Any characters beyond the 63rd are ignored 22 Operators Expressions use familiar arithmetic operators and precedence rules Functions Addition Subtraction Multiplication Division A Power Specify evaluation order 23 Buildin Functions MATLAB provides a large number of standard elementary mathematical functions including abs sqrt exp and sin Taking the square root or logarithm of a nega tive number is not an error the appropriate complex result is produced automati cally MATLAB also provides many more advanced mathematical functions including Bessel and gamma functions Most of these functions accept complex arguments For a list of the elementary mathematical functions type gtgt help elfun For a list of more advanced mathematical and matrix functions type gtgthep specfun gtgthep elmat Some ofthe functions like sqrt and sin are built in They are part of the MATLAB core so they are very ef cient but the computational details are not readily accessible Other functions like gamma and sinh are implemented in M les You can see the code and even modify it if you want Several special functions provide values of useful constants pi 314159265 i lmaginary unit xjl j Same as i eps Floating point relative precision 2 52 realmin Smallest oating point number 2 1022 realmax Largest oating point number 21023 Inf ln nity NaN Not a number ln nity is generated by dividing a nonzero value by zero or by evaluating well de ned mathematical expressions that overflow ie exceed realmax Not a number is generated by trying to evaluate expressions like 00 or Inf Inf that do not have well de ned mathematical values The function names are not reserved It is possible to overwrite any of them with a new variable such as gtgt eps 1e 6 and then use that value in subsequent calculations The original function can be restored with gtgt clear eps 24 Mathematical Expressions Like most other programming languages MATLAB provides mathematical expres sions but unlike most programming languages these expressions involve entire ma trices Here are a few examples and the resulting values gtgt rho 1sqrt52 gtgt a abs34i a gtgt Sometimes expressions or commands are so long that it is convenient to continue them onto additional lines In MATLAB7 statement continuation is denoted by three periods in succession7 as shown in the following code gtgt b 10 2 b gtgt Exercises Use MATLAB to evaluate the following expressions 1 i 2 22 15 gtlt10 4 25 gtlt 63 ln63 7 log1010 sin7r3 Qtafff g 7139 is pi in MATLAB 9 7 U 3 Vectors and Matrices For matrices7 go to MATLAB Help a Getting Started a Manipulating Matrices 31 lenerating vectors A vector can be generated in di erent ways 0 Enter an explicit list of elements gtgt v1 16 3 2 7 gtgt Use the colon operator gtgt v2 110 v2 1 2 3 4 5 6 7 8 9 10 gtgt Use MATLAB function linspace gtgt v3 linspace0110 v3 Columns 1 through 7 0 01111 02222 03333 04444 05556 06667 Columns 8 through 10 07778 08889 10000 gtgt 32 Generating matrices A Matrix can be generated by entering an explicit list of elements gtgtA163213589 A 16 3 2 1 5 8 9 gtgt MATLAB provides four functions that generate basic matrices zeros All zeros ones All ones rand Uniformly distributed random elements randn Normally distributed random elements Here are some examples gtgt B zeros24 gtgt gt F 5ones33 F 5 5 5 5 5 5 5 5 5 gtgt 33 Array Addressing 0r Indexing The element in row i and columnj of A is accessed by Aij gtgt A13 ans 2 gtgt The element in row i and columnj of B can be Changed by gtgt B11 1 gtgt 34 Arithmetic Operations on Arrays Transpose A39 gtgt C A7 c 16 3 3 5 2 8 1 9 gtgt 0 Addition AB gtgt AB gtgt 0 Multiplication gtgt A B ans 16 O O O 3 O O O 2 O O O 1 O O 0 gtgt 0 Element by element multiplication gtgt BA ans 16 O O O O O O 0 gtgt 0 Element by element division gtgt BA ans 00625 0 O gtgt Operation between scalars and arrays Addition subtraction multiplication and division by a scalar simply apply the operation to all elements of the array gtgt B A1 ans 10625 10000 10000 10000 10000 10000 10000 10000 gtgt Change the rst column of B to 1 gtgt B1 10 gtgt Concatenatz39zm is the process ofjoining small matrices to make bigger ones The pair of square brackets l is the concatenation operator For an example gtgt A B ans 16 3 2 1 10 0 0 0 3 5 8 9 10 0 0 0 gtgt Deleting Bows and Columns You can delete rows and columns from a matrix using just a pair of square brackets To delete the second column of A use 10 gtgt A2 gtgt Exercises H Create the vector 1 2 3 71 E0 Add 1 to each element of the vector 9 Multiply each element of the vector by 3 7 Square each element of the vector 9 nd the length of the vector CT Create a 3 gtlt 4 matrix A with all elements of zero 5 Create a 4 gtlt 2 matrix B with all elements of 10 00 Apply all possible arithmetic Operations between A and B 3 Change the value of the element in row 2 and column 3 to 100 H 0 Change the values of all elements in row 3 to 10 4 Script MFiles For script M les7 go to MATLAB Help a Programming and Data Types a M File Programming MATLAB is a powerful programming language as well as an interactive compu tational environment Files that contain code in the MATLAB language are called M les You create M les using a text editor7 then use them as you would any other MATLAB function or command There are two kinds of M les o Scripts7 which do not accept input arguments or return output arguments They operate on data in the workspace o Functions7 which can accept input arguments and return output arguments lnternal variables are local to the function 11 41 Scripts When you invoke a script MATLAB simply executes the commands found in the le Scripts can operate on existing data in the workspace or they can create new data on which to operate Although scripts do not return output arguments any variables that they create remain in the workspace to be used in subsequent computations For example create a le called circlejream that contains these MATLAB com mands IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII oo Matlab code circleaream 00 Compute the area of a circle IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII r 2 ooradius of a circle a compute the area A pir 2 Typing the statement circleiarea causes MATLAB to execute the commands and compute the area of the circle After execution of the le is complete the variables 7 and A remain in the workspace 42 functions Functions are M les that can accept input arguments and return output arguments The name of the M le and of the function should be the same Functions operate on variables within their own workspace separate from the workspace you access at the MATLAB command prompt The following is an example function y squarex 00 Compute the square of X 00 Comments from this line are not displayed when you use the lookfor 00 command or request help on a directory y X 2 The rst line of a function M le starts with the keyword function It gives the function name and order of arguments In this case7 there are one input argument and one output argument The next several lines7 up to the rst blank or executable line7 are comment lines that provide the help text These lines are printed when you type help square The rst line of the help text is the H1 line7 which MATLAB displays when you use the lookfor command or request help on a directory The rest of the le is the executable MATLAB code de ning the function The function can be used in several different ways square10 ysquare10 lf youre a new MATLAB programmer7 just create the M les that you want to try out in the current directory As you develop more of your own M les7 you will want to organize them into other directories and personal toolboxes that you can add to your MATLAB search path If you duplicate function names7 MATLAB executes the one that occurs rst in the search path To view the contents of an M le7 for example7 squarem7 use type squarem gtgt type squarem function y squarex 00 Compute the square of X 00 Comments from this line are not displayed when you use the lookfor 00 command or request help y X 2 gtgt Exercises H If C and F are Celsius and Fahrenheit temperatures7 the formula F 905 32 converts from Celsius to Fahrenheit Write a MATLAB code to convert a tem perature of 37 normal human temperature to Fahrenheit 986quot E0 write a function to compute sin7rt cos7rt 13 5 Basic Plotting To learn basic plotting7 go to MATLAB Help a Getting Started a Graphics The following example demonstrates how to use the plot function IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII oo Matlab code basicplottingm 00 Plot the graph of a fuction IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII X Opi1002pi y sinX figure1 plotXy Z produce a graph of y versus X Xlabel X O2pi oolabel the aXes ylabel Sine of X title Plot of the Sine Function FontSize 12 ooadd a title y2 sinX 25 y3 sinX 5 figure2 plotXyXy2Xy3 Zcreate multiple graphs with a single call to plot legend sinX sinX 25 sinX 5 Z provide an easy way to Z identify the individual plots X1 Opi1002pi X2 Opi102pi figure3 Z specify color line styles markers and line width plotX1sinX1 r X2sinX2 r linewidth 2 6 Relational Operators For the relational operators7 go to MATLAB Help a Programming and Data Types a M File Programming a Operators a Relational Operators The MATLAB relational operators compare corresponding elements of arrays with equal dimensions Relational operators always operate element by element When an array is compared with a scalar7 the scalar is compared with every element ofthe array b 1 3 gtgttfa tf 1 O gtgta1 a 1 gtgt tf1 ab tfl 1 0 gtgt 0 2 3 C 2 3 gtgt tf cgtb tf gtgt 7 Logical Operators For the logical operators7 go to MATLAB Help a Programming and Data Types a M File Programming a Operators a logical Operators gtgt A 1 2 0 gtgt B O 3 4 B O 3 4 gtgt C AampB c O 1 O gtgtDAB D 1 1 1 gtgt 8 Flow Control For ow control constructs7 go to MATLAB Help a Getting Started a Programming with MATLAB a Flow Control 81 IfElse End Constructions The if statement evaluates a logical expression and executes a group of statements when the expression is true The optional elseif and else keywords provide for the execution of alternate groups of statements An end keyword7 which matches the if7 terminates the last group of statements The groups of statements are delineated by the four keywordsino braces or brackets are involved gtgt a 1 a 1 gtgt if a A zeros33 else B ones44 end A O O O O O O O O 0 gtgt a O a 0 gtgt if a A zeros33 else B ones 44 end B 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 gtgt 82 For Loops The for loop repeats a group of statements a xed7 predetermined number of times A matching end delineates the statements The following program uses the for loop to compute the sum 1 2 9 10 gtgt sum 0 gtgt for n110 sum sum n end gtgt sum gtgt The following program uses the for loop to make sine wave movie 00 moviemakerm oouse the function movie2avi to make a movie Clear all t O O 01 4pi y sint fc O tlength lengtht for n 110tlength plott1 ny1 n b tnyn 7r gt linewidth 2 Xlabel t fontsize 18 ylabel y fontsize 18 grid on axis0 maxt01 11 11 pause01 str Sine Wave t 7 num2strtn titlestr fontsize 16 fc fc1 Ffcgetframegcf end moviename sinewave avi 7 movie2aviF moviename fps 6 Colormap jet quality 100 To nd functions of Audio and AudioVideo7 go to MATLAB Help a MATLAB endverbatim Functions By Category a File IO a Audio and AudioVideo 83 While Loops The while loop repeats a group of statements an inde nite number of times under control of a logical condition A matching end delineates the statements The following program uses the while loop to compute the sum 12 9 10 gtgt sum O gtgt while nlt1o sum sum n n n 1 gtgt sum sum gtgt

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "I signed up to be an Elite Notetaker with 2 of my sorority sisters this semester. We just posted our notes weekly and were each making over $600 per month. I LOVE StudySoup!"

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.