1 / 22

# To days Outline - PowerPoint PPT Presentation

To days Outline. Linear Equations ODE Integration Handle Graphics. Exercises on this days topics. Linear Equations. Linear equations Using left division MATLAB uses Gaussian elemination Has the solution in MATLAB X=A\Y Example: Solve the system of linear equation:. ODE.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'To days Outline' - leanna

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

• Linear Equations

• ODE

• Integration

• Handle Graphics.

• Exercises on this days topics

Lecture 5

• Linear equations

• Using left division

• MATLAB uses Gaussian elemination

• Has the solution in MATLAB

• X=A\Y

• Example:

Solve the system of linear equation:

Lecture 5

• MATLAB can solve system of first order ordinary differential equations with known initial condition.

• MATLAB offers a number of different solvers

• ode45

• This is the typical first solver to try on a new problem.

• ode15s

• This is typical to try if ode45 fails or are too inefficient. Solves stiff problems.

• Stiff problem are described as problem in which the time constants vary a lot.

Lecture 5

• General form

• [time,x]=solver(fh,t,x0)

• time: Time values

• x: contains the solution for each time value

• solver: one of MATLAB’s ode solvers

• fh: A function handle to the function that describes the differential equations

• t: is the time span T0 to TFINAL

• x0: Initial condition

Lecture 5

Example:

Solve the differential equation:

Lecture 5

Lecture 5

• Higher order differential equations must be rewritten into system of first order differential equations.

y

b

m

F

k

Lecture 5

• Trapezoidal numerical integration.

• z = trapz(x,y)

• computes the integral of y with respect to x using the trapezoidal method.

• The trapezoidal technique is used when we only know the integrand in a number of specific points.

• With a smaller delta-x the numerical integration becomes more accurate

Lecture 5

• A set of low level functions that control the characteristic of a graphic object.

• Changing grids, line color etc. that is not supported by the standard LinSpec option in the plot command.

• MATLAB graphics system is based on a hierarchical system of Graphical Objects

Lecture 5

• Each graphical object are known by a unique name: Handle

• Each graphical object has special data: properties

• A handle is automatically returned by any command that creates a graphic object.

• Hndl=figure

Lecture 5

Lecture 5

• When an object is created all of its properties are initialized to default values.

• plot(y) uses the default line color, line style, line width etc.

• All properties can be examined using:

• get(Handle,’PropertyName’) ;

• All properties can be changed using:

• set(Handle,’PropertyName’,Value1’,….);

• If value are left out MATLAB display a list of possible property values for that actual property name

Lecture 5

• To view all properties:

• x=[0:0.1:2];

• y=x.^2;

• Hndl=plot(x,y) %Handle to the line.

• result=get(Hndl)

• result will be a structure containing all properties to the line

Lecture 5

Lecture 5

• To change the line width from default 0.5 to 5:

• set(Hndl,’LineWidth’,5)

Lecture 5

• Functions that return handles

• gcf

• Get current figure.

• gca

• Get current axes in the current figure.

• gco

• Get current object in the current figure.

• findobj

• Finds a graphics object with a specific property value

• The current object is defined as the last object clicked on with the mouse.

Lecture 5

• Position of figure Objects

• [left bottom width height]

• Units can be: pixels, inches, cm, points and normalized coordinates.

• Normalized coordinates are between 0-1.

• (0,0) = Lower left corner

• (1,1) = Upper right corner

• Using normalized coordinates will make the figure to appear in the same relative position regardless of screen resolution.

• Normalized coordinates are recommended to use if possible

• Lecture 5

• Position of axes and uicontrol Objects

• Also a 4-element vector.

• [left bottom width height]

• Position is specified relative to the figure that contains the object.

• Default units:

• Normalized coordinates within the figure.

Lecture 5

• Position of text Objects

• The position of a text object refers to the actual axes.

• x,y in 2D

• x,y,z in 3D

• The position of the text object relative to a specified point is controlled by:

• HorizontalAlignment

• {Left},Center,Right

• VerticalAlignment

• {Middle}, Top, Cap, Baseline, Bottom

Lecture 5

Example:

- Construct a dartboard with 10 circles.

- Add text in each circle what the point would be if the dart should hit within that circle.

- Construct a frame around the dartboard.

- Simulate that a person throw 10 darts at the

board with the standard deviation 4 in x and y direction.

Lecture 5

Lecture 5