text:
User:Eml4500.f08.wiki1.aguilar/TeamCollaboration

EML4500 Fall 2008 Notes
These class notes cover lectures from the first day of class up to the material covered in the lecture of Friday, Sept. 5th 2008. Brooks Handy is this section's primary author.

Syllabus
{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 EML 4500 Finite Element Analysis and Design (FEAD) [http://clesm.mae.ufl.edu/wiki.pub/index.php/Main_Page |Dr. L. Vu-Quoc|] Fall 2008

Course description
Fundamentals of the finite element (FE) method and applications to structural, solid, and bio-mechanics. Principle of vitual work. Derivation of the stiffness matrices for truss, beam, and solid elements. Coordinate transformation for structural elements in 3-D. Direct stiffness method. Static analysis of FE systems with a matrix linear algebra approach, internal structure of a FE code, coding and plotting. Linear stability analysis of truss and beam structures. Applications to aerospace structures and biomechanics. Other topics such as axisymmetric solid elements, dynamic analysis, substructuring analysis, etc. could be taught, depending on the class and the instructor.

Course objective
This course is intended to be the first Finite Element Method (FEM) course for all engineering students. Its objective is to develop a basic understanding of the fundamentals of the FEM through careful derivation of the stiffness matrix from first principles. Fundamental concepts of linear algebra are taught, e.g., inversion and transpose of matrix product, matrix partitioning and solution by static condensation, determinant, eigenvalue problems, etc. For trusses and beams, coordinate transformation of the degrees of freedom from local to global coordinates and the direct stiffness method to assemble element matrices into global matrix is emphasized. The 3-D aspect is emphasized for all truss and beam elements. Euler-Bernoulli beam theory with shear correction, in 3-D, is taught in detail. The connection of linear algebra to the FEM is emphasized, e.g., rigid-body modes and the singularity of the element stiffness matrix. For solid elements, an introduction to the principle of minimum potential energy and the principle of virtual work taught. Commercial codes can be used to train students on practical aspects of FE analysis. Some aspects of buckling analysis and dynamic analysis, and their connection to linear algebra, are addressed.

Topics
* 3-D truss, beam, and solid structures. Beams with shear correction. * Matrix algebra and its application to finite element solution. * Construction of a FE code, coding and plotting. * Linear stability (buckling) analysis of truss and beam structures. * Applications to mechanical and aerospace engineering, biomechanics, and other engineering    areas (e.g., circuit analysis, heat conduction, etc.) * Class projects: Students will "design" and solve open-ended problems that involve FE model    building and analysis of complex problems (e.g., prostheses, organs, airframes, automobiles,     off-shore platforms, etc.). * Other advanced topics: axisymmetric solid elements, dynamic analysis, nonlinear analysis,    substructuring analyis, etc. depending on mutual interest between the students and the     instructor.

Text and Other Resources
M. Asghar Bhatti, Finite Element Analysis With Mathematica and Matlab Computations and Practical Applications: Fundamental Concepts John Wiley & Sons (February 4, 2005) ISBN: 0471648086 Fri, 07 Jul 2006.

Recommended
* J.S. Przemieniecki, Theory of Matrix Structural Analysis, Dover, 1985, (McGraw-Hill, 1968). ISBN 0-486-64948-2 (Paperback). Library call no. 624.171 P973t. * Y.W. Kwon and H. Bang, Finite Element Method using MATLAB, 2nd edition, CRC Press, 2000. ISBN 0-8493-9653-0. Library call no. TA347.F5 K86 1997 (first edition). * Matlab Guide to Finite Elements: An Interactive Approach, Peter Issa Kattan, Springer Verlag   (February 15, 2003), ISBN: 3540438742.

Web pages of related courses
Fall 2006: EML 4500 Finite Element Analysis and Design. Fall 2003: EML 4500 Finite Element Analysis and Design. Spring 2000: EAS 4210C Finite Element for Engineering Mechanics Spring 1999: EAS 4210C Aerospace Structures 2

Grade determination:
Tentatively, homework/project and class participation including bonuses (31%), exam1 (23%), exam2 (23%), exam3 (23%). Adjustments to the weights could be made at the end of the course.

Homework:
There will be HW assignments, which are to be solved following Cooperative Learning Techniques. HW should be thought of as mini projects, which include "hand solution" with the help of Matlab and the use of the Matlab codes that come with the textbook. Students will also be asked to develop their own Matlab codes. For a tutorial on how to use Matlab, see [|Matlab] matters. See the [|course policy] for more details.

Course outcome:
Upon a successful completion of this course, a student is expected to: The above outcomes are consistent with the Departmental and College of Engineering Educational Objectives and meet the following ABET criteria:
 * 1) Have an understanding of matrix linear algebra and its role in the solution of FE systems.
 * 2) Master the derivation of various structural elements in 3-D (truss, beam), and the associated transformation of the stiffness matrix from local coordinates to global coordinates by the Principle of Virtual Work.
 * 3) Know how to correct for shear deformation in Euler-Bernoulli beam.
 * 4) Have a notion of the derivation of the stiffness matrix of solid elements, and their use in a commercial FE code.
 * 5) Know that the concepts of the FEM are also applied to fields other than structural and solid mechanics, e.g., circuit analysis, heat conduction, fluid mechanics, electromagnetics, etc.
 * 6) Develop skills to tackle open-ended problems in FE analysis and design.
 * 7) Develop communication skills, presentation skills, report-writing skills, team work (cooperative learning).
 * 1) Ability to apply knowledge of mathematics, science, and engineering.
 * 2) Ability to identify, formulate, and solve engineering problems.
 * 3) Ability communicate effectively.
 * 4) Ability to use the techniques, skills, and modern engineering tools necessary for engineering practice.

This page was last updated on: Tue, 12 Aug 2008, 17:56:54 EDT

 * }

Class Structure
The class is structured to focus on teamwork. Everyone in the class is broken up into groups of 5-6 members. In order to facilitate members working together, Wikiversity plays a vital role in assignments and projects.

Through Wikiversity, the members are able to access other group members information and everyone is able to work on an assignment or project. Wikipedia and class guidelines provide for a safe and effective method for project submittal and significantly reduce the chances of data loss.

Labeling Conventions
Bar Element 1: Global Free-Body Diagram

The structure should be labeled using numbers in triangles to identify elements, numbers in circles to identify global nodes, and numbers in squares to identify local nodes (in local free body diagrams). Draw free body diagrams to identify all forces and reactions. Draw a free body diagram for each element. Identify forces using Fie to describe the ith internal force on element e. Identify displacements with die using the same labeling convention.

Describe elements as springs
Next we must understand that each element can be described as a spring, under force F, displacement d, and with a spring constant K. The governing equation is then F=Kd. When considering a spring with 2 free ends, it can be analyzed using a matrix equation F=Kd.

6 Steps of the FEM
The Finite Element Method (FEM) is a six step process. The first step is to draw a global picture at a structural level including the global degrees of freedom (DOF) and global forces. The displacement DOFs can be partitioned into a known part (constraints) and an unknown part (must be solved using FEM). The global forces can also be partitioned into a known part (applied forces) and an unknown part (reactions). The second step is to draw individual element pictures including DOFs and forces in either the global coordinate system, or a local coordinate system. The third step is determine the global force-displacement relationships. Assemble the element stiffness and force matrices using global coordinates in the form Kd=F where K is a nxn matrix, d is a nx1 matrix, and F is a nx1 matrix. The fourth step is to eliminate the known DOFs. The stiffness matrix is non-singular and therefore invertable. We reduce the equation to  d = K -1 F . The fifth step is the compute the element forces from the known d and determine the element stresses. The sixth step is to compute the reactions.

Meeting 8 Lecture Notes (12 Sep 08)
[Kij]6x6{dj}6x1 = {Fi}6x1

Knxn = [Kij]nxn = global stiffness matrix

dnx1 = {dj}nx1 = global displacement matrix

Fnx1 = {Fi}nx1 = global force matrix

k(e)4x4d(e)4x1 = f(e)4x1

k(e)4x4 = [k(e)ij]4x4 = elemental stiffness matrix

d(e)4x1 = [d(e)j]4x1 = elemental displacement matrix

f(e)4x1 = [f(e)i]4x1 = elemental force matrix

To get from global matrices  to  elemental matrices :
Use an  assembly process

Global level:
{d1, d2, d3, d4, d5, d6}

Elemental level:
Elem. 1: {d1(1), d2(1), d3(1), d4(1)}

Elem. 2: {d1(2), d2(2), d3(2), d4(2)}

Identification of Global-Local (Elemental) Degrees of Freedom (DOF's):
Global Node 1:

d1 = d1(1)

d2 = d2(1)

Global Node 2:

d3 = d3(1) = d1(2)

d4 = d4(1) = d2(2)

Global Node 3:

d5 = d3(2)

d6 = d4(2)

Conceptual Step of Assembly:
(Topology of  K )

MATLAB Tutorial
This section is based on the MATLAB primer tutorial that was written by Mermit Sigmon of the University of Florida. This section had multiple primary authors and was separated as follows: Sections 1-5: Bryan Ambrosio Sections 6-9: Michael Aguilar Sections 10-12: Lyndsey Schaet Sections 13-17: Clayton Brannon Sections 18-19: Benjamin Oatley

{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 Sections 1-5

Section 1 How to Access MATLAB
After logging onto a computer with MATLAB installed, run the system command matlab or click on the desktop icon. To exit MATLAB, enter quit or exit in the MATLAB command window, or click on the File menu and select Exit MATLAB.

When the Editor in MATLAB is opened, it is convenient to have the Editor and Command windows opened separately. The specifics of the Editor are covered later on in this tutorial.

Section 2 Entering Matrices
MATLAB is based around operating with matrices. In fact, MATLAB is an abbreviation for Matrix Laboratory. The program can interpret these matrices as either scalars or vectors.

Matrices can be created by entering an explicit list of elements, generating built in statements and functions, creating a disk file with a local editor, or loading external data files or applications.

The following are all examples for creating matrix A, which is a 3x3 matrix. A = [1 2 3; 4 5 6; 7 8 9]

A = [1,2,3;4,5,6;7,8,9]

A = [ 1 2 3	4 5 6	7 8 9]

Notice that the elements in the rows of the matrix can be separated by commas or blank spaces.

The following is an example of how to enter a number in exponential form.

x = 2.34e-9

Notice when the number in entered, there are no spaces in between the e.

MATLAB is capable of doing computations with complex numbers. The following are examples of how to create complex matrices.

A = [1 2;3 4] + i*[5 6;7 8]

A = [1+5i 2+6i;3+7i 4+8i]

Notice when the complex numbers were listed inside the matrix, no blank spaces were used. It should also be noted that either i or j can be used as the imaginary unit. Also, if i or j are assigned as variables to represent a new value, they will not retain their value as an imaginary number. For example if the user enters the command

i = 5

then i will no longer be equal to 'sqrt(-1)', it will be equal to 5.

If a large matrix must be entered, creating an ASCII file is a good option because it can make it easier to correct errors. If an ASCII file is created and named data.ext, simply type load data.ext into the MATLAB command line and press enter. This command will read the file and save it as the variable data. MATLAB also has built in functions such as rand, magic, and hilb. If rand(n) is typed into the command line, MATLAB will create a n x n matrix with randomly generated numbers distributed uniformly between 0 and 1. If rand(m,n) is typed into the command line, MATLAB will create a m x n matrix with the same criteria as before. If magic(n) is typed into the command line, MATLAB will create an integral n x n matrix which is a magic square. This means all the rows, columns, and diagonals have a common sum. If hilb(n) is typed into the command line, MATLAB will create a n x n Hilbert matrix.

Individual entries in a matrix can be easily referenced. For example,

A(2,3)

selects the value in the second row, third column of matrix A. Also

X(3)

Would select the third coordinate of vector X.

Section 3 Matrix and Array Operations
The following matrix operations are available in MATLAB:

+	addition -	Subtraction ^	power ‘	conjugate transpose \	left division /	right division
 * multiplication

Since a scalar value entered into MATLAB is stored as a 1 x 1 matrix, these operations also apply to those values. If MATLAB is told to perform an operation that is not possible for a specific matrix, an error message will appear on the screen.

Matrix division can sometimes be confusing in MATLAB. The difference in right and left division is shown below.

x = A\b is the solution of A*x = b

x = b/A is the solution of x*A = b (another way of writing this could be x = (A’\b’)’ )

It is also important to note that addition and subtraction operate entry wise, but multiplication, power, and left and right division operate as matrix operations. These matrix operations can operate as entry wise operations by placing a period in front of them. An example is

[1,2,3,4].*[1,2,3,4]	or 	[1,2,3,4].^2

Both of these operations will give [1,4,9,16] as the solution.

Section 4 Statements, Expressions, and Variables and Saving Sessions
MATLAB uses expression language. This means when values are typed in, they are entered in the form of variable = expression or just as expression. For example,

x = 5*4

The evaluation of this expression is created as a matrix and displayed on the screen, such as

x = 20

If a variable and equal sign are not used, the result is automatically saved as the variable ans.

The user can also decide to continue the statement to the next line by using three or more periods (…) followed by enter, or several statements can be placed on a single line by separating them with commas (,) or semicolons (;).

If the variable is rather large, it may be useful to suppress the statement. By placing a semicolon (;) at the end of a statement, the assignment is carried out, but the result will not be printed on the screen.

It is also important to note that MATLAB is case sensitive. For example, alpha is not the same as Alpha.

In order to see a list of variables that are currently being used in the workspace, type who (or whos) in the command line. If a variable needs to be cleared from the workspace, enter clear variablename'. If clear is entered into the command line, all nonpermanent variables will be cleared.

If the unit round off needs to be changed, type in eps (epsilon) to have MATLAB use a round off of 10^-16. This can be useful in specifying tolerances for convergence of iterative processes.

Sometimes a computer will enter a loop that does not stop or takes too long to calculate. These computations can be stopped in MATLAB by pressing CTRL-c.

When MATLAB is closed, all of the variables in the workspace are deleted. If these variables need to be saved, enter save in the command line before closing the program. These variables are written to a disk file named matlab.mat. When MATLAB is started again, enter the command load and the variables will be restored to the workspace.

Section 5 Matrix Building Functions
The following are convenient matrix building functions:

eye		identity matrix zeros 		matrix of zeros ones		matrix of ones diag		create or extract diagnols triu		upper triangular part of a matrix tril		lower triangular part of a matrix rand		randomly generated matrix hilb		Hilbert matrix magic		magic square toeplitz	see help toeplitz

For example, zeros(m,n) creates a m x n matix of zeros, and zeros(n) produces a n x n matrix of zeros. If A has already been defined as a matrix, then zeros(size(A)) will create a matrix of zeros that is the same size as matrix A.

If x has already been defined as a vector, diag(x) creates a diagonal matrix with x down the diagonal. If A has already been defined as a square matrix, then diag(A) creates a vector consisting of the diagonal of A.

Matrices can also be built from blocks consisting of other matrices. For example, if A is defined as a 3 x 3 matrix, then B = [A, zeros(3,2); zeros(2,3), eye(2)] will be 5 x 5 matrix.

 * }

{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 Sections 6-9

Section 6 For, While, If, and Relations
As with other computer programming languages, MATLAB has the flow control statements For, While, If, and Relations.

For
For loops are started with the command. For example, one of the most simple examples of a for-loop is:

for j=1:4, j end Here, a loop is cycled through, setting the variable j to 1, then 2, then 3, and then 4, and showing each of these outputs in the command window.

Another example, for a given "n", the statement: x=[]; for i=1:n, x=[x,i^2], end which is the same as x=[]; for i=1:n x=[x,i^2] end will produce a certain "n" vector. The statement, x=[]; for i=n:-1:1, x=[x,i^2], end produces the same vector but in the reverse order.

The statements for i=1:m for j= 1:n H(i,j) = 1/(i+j-1); end end H generate an m-by-n Hilbert matrix.

Note: Using the semicolon in the code stops MATLAB from printing unwanted intermediate results.

MATLAB allows for any matrix to be used in place of 1:n. The variable just consecutive assumes the value of each column of the matrix.

While
While loops are done in the exact same way using the command. The general form of the  loop is:

relation

 * statements

As expected, the  loop will continue to be executed as long as the relation remains true.

A basic  loop example is given below. n=0; while n<5 n=n+1; n end This loop cycles through, increasing the variable n by 1 until the relation is no longer true.

If
The  command allows for various if-then statements to be executed. The general form of the  loop is:

 * relation

 * statements

As expected, the  command executes only when the relation is true.

A basic  command example is given below. n=0; if n==0 n=2; n end Here, we set n=0, so the relation is true and theprint statement exectues accordingly. If the code was repeated, n would now be equal to 2, so nothing would be printed.

Multiple branching is also possible. This is done with  and   commands, as shown below. n=x; if n>0 m='Positive'; elseif n<0 m='Negative'; else m='0'; end

We can see how the output changes depending on the value of x.

Relations
MATLAB uses typical programming relationship operators: <    less than >    greater than <=   less than or equal to     >=    greater than or equal to     ==    equal ~=   not equal Note: The assignment statement "=" is different from the "==" relationship operator.

You can also use these logical operators in conjunction with the relationship operators: &    and |    or     ~     not

When applied to scalars, the relation is the scalar 1 if the relation is true, and 0 if the relation is false. For example, executing 1<2 prints "ans = 1", however, if you enter 2<1, the result is "ans = 0".

These relationship operators can also be applied to matrices. If the are the same size, the output is a matrix of 0's and 1's giving the value of the relation between corresponding entries.

Note: if you wish for a statement to be executed if matrices A and B are equal, you could type:

if A == B  statement end

but the seemly obvious opposite below would not execute as expected:

if A ~= B  statement end This statement would only execute if each of the corresponding entries was different. So, alternatively, to execute a statement from two matrices that were even one entry different, you would use:

if A == B else statement end

Section 7 Scalar Functions
Many MATLAB functions are used mainly on scalars. A list of the most common include: sin            asin             exp                    abs               round cos            acos             log (natural log)      sqrt              floor tan            atan             rem (remainder)        sign              ceil

Note: The operate element-wise when applied to a matrix.

Section 8 Vector Functions
Other MATLAB functions operate essentially on a vector (row or column), but act on an m-by-n matrix (m$$>=$$2) in a column-by-column fashion to produce a row vector containing the results of their application to each column.

For example: m=[1,3;2,4]; mean(m) gives the result: ans =

1.5000   3.5000 As you can see, the mean of 1 and 2 is 1.5 and the mean of 3 and 4 is 3.5.

This means that in order to find the maximum entry in a matrix A, we use max(max(A)) rather than max(A).

Note: Row-by-row action can be obtained by using the transpose; for example, mean(B')'.

Some of these vector functions are listed below: max         sum          median          any min         prod         mean            all sort                     std

Section 9 Matrix Functions
MATLAB is especially useful when using any of its various matrix functions. Some of the most useful include: eig      eigenvalues and eigenvectors chol     cholesky factorization svd      single value decomposition inv      inverse lu       LU factorization qr       QR factorization hess     hessenberg form schur    schur decomposition rref     reduced row echelon form expm     matrix exponential sqrtm    matrix square root poly     characteristic polynomial det      determinant size     size norm     1-norm, 2-norm, F-norm, infinite-norm cond     condition number in the 2-norm rank     rank

Note: Some of these functions may have single or multiple output arguments. While  produces a column vector containing the eigenvalues of A,   produces a matrix U whose columns are the eigenvectors of A and a diagonal matrix D with the eigenvalues of A on its diagonal.

For example, if m=[1,2,3;4,5,6;7,8,9], then [u,d] eig(m) outputs:

u =

-0.2320  -0.7858    0.4082        -0.5253   -0.0868   -0.8165        -0.8187    0.6123    0.4082

d =

16.1168        0         0              0   -1.1168         0              0         0   -0.0000
 * }

{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 Sections 10-12

Section 10 - Command Line Editing and Recall
This section discusses the ease of editing commands using the arrow keys on the keyboard and recalling command lines in Matlab without having to write M-files (section 12).

Editing commands is easy in Matlab. The cursor can be placed anywhere in the command line using the mouse, left/right arrow keys, and backspace. This simple method of editing does not exist in other programming languages such as Fortran. On the PC's that most of us use, the Home, End, and Delete keys can also be used to place the cursor to make revisions. Using the up/down arrow keys allows the user to scroll through past command lines. This allows the user to simply copy and paste a command they want to use again. Once pasted, the user can also alter the command line. This is very useful if you were using a long linear regression equation and only one constant or variable needed to be replaced.

Section 11 - Submatricies and Colon Notation
This section covers the use of colon notation for matricies. It also discusses subscripting by integral vectors. Both of these methods are used to easily manipulate complicated vectors and submatricies. Creative use of the colon notation discussed here can often eliminate the need for loops thus making the execution of MATLAB code faster.

Vectors typically seen as [a b c d e f....n] can take on the notation of [a:n] in Matlab. Using this colon notation makes it easier and simpler to read and execute. One example of the use of this expression 1:5. This expands out to the row matrix [1 2 3 4 5]. When using this notation, the vector does not need to increment by just one either. Adding a middle term defines what level the vector should increment. For example, the expression 0.2:0.2:1.2 is the vector [0.2 0.4 0.6 0.8 1.0 1.2]. Another example is the expression 5:-1:1 gives [5 4 3 2 1].

The colon notation makes it easy to access submatricies as well as alter a given matrix. Below are some examples.

If A is a predefined matrix of arbitrary size n by n, the notation A(1:4,3) is the column vector consisting of the first four entries of the third column of A.

Using the colon by itself takes an entire row or column from a given matrix, in this case the matrix A. For example, the expression A(:,3) is the entire third column of A. The expression A(1:4,:) is the first four rows of A.

Creating new matricies using arbitrary integral vectors also proves useful in Matlab. The expression A(:,[2 4]) is a matrix whose two columns consist of column 2 and 4 of A. This method of manipulation can also be used in an assignment statement. One example of this is the expression A(:,[2 4 5]) = B(:,1:3) replaces columns 2, 4, and 5 of A with the first three columnds of B. Running this command prints and assigns the entire altered matrix A.

This notation also makes multiplying matricies easier. The expression A(:,[2,4]) = A(:,[2,4])*[1 2;3 4] multiplies the columns 2 and 4 in matrix A by the 2x2 matrix [1 2;3 4]. Running this command once again prints the entire altered matrix.

By comparison to other coding languages, using this notation makes adds to Matlab's usefulness when dealing with vectors and matricies.

Section 12 - M-files
M-files are MATLAB files with the ".m" file extension. These are usually created with a local editor, and contain a sequence of statements that can be executed. There are two types of M-files, script files and function files.

Script Files
A script file consists of a sequence of normal MATLAB statements. For example, if you create a script file called, then typing   into the command window will execute the statements that are in the script.

Note: Variables used in scripts are global and will interfere with any variables of the same name within the current MATLAB session.

Function Files
Function files allow you to create your own functions specific to what you are trying to do, and these will have the status as any other function within MATLAB. Function file variables are local by default, but can be set as global.

Example: function a = randint(m,n) %RANDINT Randomly generated integral matrix. %randint(m,n) returns an n-by-m matrix with integers between 0 and 9 a = floor(10*rand(m,n));

You would save this code as a diskfile with the name. Notice that the first line of code gives the name of the function, the input arguments, and output arguments; this line is the difference between a script file and a function file.

You would execute this function file by entering. This sends  and   to be sent as   and   respectively with the output result set as. Again, these variable are, by default, local variables.

The function are flexible in their use of inputs and outputs. The use of, ("number of input arguments") allows you to set a default value of an omitted input variable. A function may also have multiple output arguments.

To make comments, use '%' and the rest of the line is ignored by MATLAB. It is considered correct to include some beginning comment lines to describe the use of the function, and can displayed for example if  is entered. You should also try to write in efficient code, using vectorized operations and avoiding loops. If  loops must be used, you can make them faster by pre-allocating any vectors or matrices to which the output is stored.

Some MATLAB functions are built in while others are distributed as M-files. A listing of non-built-in functions can be seen with the MATLAB command  functionname.

 * }

{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 Sections 13-17

Section 13 Text Strings, Error Messages, Input
Text strings can be entered into MATLAB using single quotation marks as follows:

string='text string'

Using the disp function, text strings can be displayed in the following way:

disp('displays text string')

Error messages can be displayed with the error function:

error('error message')

which is useful with M-files, as an M-file execution will be aborted.

Within M-files, the user may be prompted to input data using the input function:

variable=input('Enter number: ')

The variable is assigned the input value and execution continues.

Section 14 Managing M-files
Creating or editing an M-file from within MATLAB can be accomplished using the !-feature. This is useful because all variables would be reset upon exiting MATLAB. System sommands such as copying, editing, and printing can be executed using this feature. As an example, !ed can be used to access the system editor:

>> !ed fileforediting.m

After editing the file, the user will return to MATLAB as it was before entering the editor.

In addition, the editor and MATLAB may be active simultaneously on systems permitting multiple processes, suspending one while working in another.

Debugging tools can be seen using the help dbtype command.

The present working directory can be viewed with the pwd command and cd can be used to change directories. The dir and ls commands list the contents of the directory and what lists the M-files within the directory only. The delete command deletes a diskfile. The type command prints a M-file to the screen.

M-files must be stored in a MATLAB-accesible directory, such as the present working directory. Typically, these files are stored in a subdirectory of the home directory titled matlab.

Section 15 Comparing Efficiency of Algorithms: Flops, Tic and Toc
Efficiency can be measured by counting the floating point operations (flops)performed or the elapsed time.

The flops count is reset using flops(0). Using the command flops again immediately after the operation gives the flops count.

flops(0), var=2+2; flops

The time elapsed for any given command can be measured using the tic command immediately before the command and toc just after it.

tic, command, toc

The processing speed available for the operation will also affect these measurements.

Section 16 Output Format
Computations within MATLAB are performed using double precision, though the format with which the results are shown can be changed with the following commands:

format short          fixed point with four decimal places (default) format long           fixed point with fourteen decimal places format short e        scientific notation with four decimal places format long e         scientific notation with fifteen decimal places format rat            approximation by ratio of small integers format hex            hexadecimal format format bank           fixed dollars and cents format +              +, -, blank

Changes to format remain until changed again.

Section 17 Hardcopy
Hardcopy is obtained using the diary command. The command below causes text that appears subsequently on the screen to be written to the named diskfile (default: diary):

diary named diskfile

The command diary on will write text to the file until the command diary off is called.
 * }

{| class="toccolours collapsible collapsed" width=100% ! colspan="2" |

 Sections 18-19

Section 18: MATLAB Graphics
One of the functions of MATLAB is the ability to produce several different types of curves and plots. *These include the following, followed by their respective commands:

planar plots of curves		                       plot 3-D plots of curves				       plot3 3-D mesh surface plots				       mesh 3-D faceted surface plots				surf

Planar Plots
For example, to plot a cosine function over the interval -5 to 5 on an x-y plot of the elements of x versus the elements of y, the command is as follows:

x = -5 : .01 : 5 y = cos(x) plot(x,y) Another example of a sample function would be to plot the function y=e^(x^3 )over the interval of -3.5 to 3.5 on an x-y plot of the elements of x versus the elements of y, the command is as follows: x = -3.5 : .01 : 3.5 y = exp(x.^3) plot(x,y)

“fplots”
The function “fplot” allows the user to graph a function with great ease and efficiency. To plot the above function, the function must first be defined in an M-file (e.g. “expnormal.m”). The M-file for the above function would read as follows: function y = expnormal(x) y = exp(x.^3) followed by the command fplot(‘expnormal’, [-3.5,3.5])

Parametric Curves
Parametric curves can be created in MATLAB. The commands for an example parametric function are as follows: t = 0: 0.01: 2*pi x = sin(5*t) y = cos(3*t) plot(x,y) MATLAB graphs can be assigned with titles, labeled axes, as well as text placed within the graph. These options with their respective commands are as follows: graph title					title x-axis label					x label y-axis label					y label place text on graph using mouse		       gtext position text on coordinates			text For example, to assign the label “Force (N)” to the x-axis, the appropriate command would be as follows: xlabel(‘Force (N)’)

Axis Reformatting
MATLAB automatically formats the axes of graphs with an auto-scale. The command “axis” following the “plot” command can override this auto-scale. Some additional options with their respective commands are as follows: set axis scale to prescribed limits			axis([xmin, xmax, ymin, ymax]) freeze scale for subsequent graphs			axis(axis) return to auto-scale					axis auto returns vector v showing current scale		       v = axis same scale on both axes				       axis square same scale and tic marks on both axes		       axis equal turn off axis scaling and tic marks			axis off turn on axis scaling and tic marks			axis on

Superimposing Plots on Top of Each Other
In MATLAB it is possible to place multiple plots on a single graph. One example of such a case is listed in the following commands: x = 0: .01: 2*pi y1 = cos(x) y2 = cos(3*x) y3 = cos(5*x) plot(x,y1,x,y2,x,y3) The same plots can be generated using a matrix Y, as follows: x = 0: .01: 2*pi Y = [cos(x)’, cos(3*x)’, cos(5*x)’] plot(x,Y) Another way to superimpose plots on each other is with the command “hold”. “hold on” will freeze the current plot and will superimpose subsequent plots on it. “hold off” will release the specified hold.

Overriding Default Linetypes, Pointtypes, and Colors
One example of overriding defaults for a dotted line and a line with circles placed at each node is as follows: x = 0: .01: 2*pi y1 = cos(x) y2 = sin(3*x) plot(x,y1, ‘:’,x,y2, ‘o’) Options for linetypes includes the following: solid (-) dashed (--) dotted dashdot (-.) Options for marktypes include the following: point (.) plus (+) star(*) circle (o) x-mark (x) Options for colors include the following: yellow (y) magenta (m) cyan (c) red (r) green (g) blue (b) white (w) black (k) For example, to plot a blue dotted line, the commands are as follows: plot(x,y,’b:’)

Graphics Hardcopy
With the command “print”, MATLAB will send a high-resolution copy of the current graphics figure to the computer’s default printer. The command “printopt” specifies the default setting used the by the “print” command. The command “print filename” saves the current graphics figure to the specified filename. 3-D Line Plots MATLAB can also create curves in three dimensions with the command “plot3”. For example, a parametric graph in three dimensions can be created with the following commands: t = .01: .01: 2*pi x = sin(2*t) y = cos(t) z = t.^2 plot3(x,y,z)

3-D Mesh and Surface Plots
The command “mesh” creates a three-dimensional wire mesh surface plot.

The command “surf” creates a three-dimensional faceted surface plot.

For example, the graph of z=e^(y^3+x^2 )over the square [-3,3] x [-3,3] can be created with the following commands: xx = -3: .1 :3 yy = xx [x,y] = meshgrid(xx,yy) z = exp(y.^3 + x.^2) mesh(z)

Color Shading and Color Profile
The command “shading” edits the color shading of different surfaces in MATLAB. The three settings and their respective commands are as follows: faceted (default)		shading faceted interpolated			shading interp flat				shading flat Color profiles in MATLAB can also be edited using the command “colormap”. Possible colormap options include the following: hsv (default) hot cool jet pink copper flag gray bone For example, to set the color profile of a figure to hot, the command is as follows: colormap(hot)

Section 19: Sparse Matrix Computations
MATLAB has the capability of significantly reducing the computation time in regards to solving matrices. MATLAB has two storage modes, full (default) and sparse.

For a matrix A, the command “nnz(A)” would return the number of nonzero elements in matrix A.

To create a sparse matrix, the necessary commands are as follows: m = 5 n = 5 e = ones(n,1) d = -2*e T = spdiags([e,d,e], [-2,0,2], m, n) The sparse analogs of eye, zeros, ones, and randn are as follows: speye sparse spones sprandn The command “sparse” allows for the generation of a sparse matrix from the listing of its nonzero entries. i = [1 2 3 5 5 5] j = [1 2 3 3 2 1] s = [2 3 4 5 6 7] S = sparse(i, j, s, 4, 3), full(S) The command “sparse(i, j, s, m, n) is made up of several components. i and j list the row and column indices and s lists the nonzero entries of S. m and n are the dimensions of the matrix S.
 * }

Authors
Clayton Brannon Eml4500.f08.wiki1.brannon 01:06, 18 September 2008 (UTC)

Benjamin Oatley Eml4500.f08.wiki1.oatley 21:22, 17 September 2008 (UTC)

Bryan Ambrosio Eml4500.f08.wiki1.ambrosio 14:36, 18 September 2008 (UTC) Lyndsey Schaet Eml4500.f08.wiki1.schaet 17:49, 19 September 2008 (UTC)


text:
User talk:Eml4500.f08.wiki1.handy

 Hello Eml4500.f08.wiki1.handy, and welcome to Wikiversity! If you need help, feel free to visit my talk page, or contact us and ask questions. After you leave a comment on a talk page, remember to sign and date; it helps everyone follow the threads of the discussion. The signature icon in the edit window makes it simple. To get started, you may

 * Take a guided tour and learn to edit.
 * Visit a (kind of) random random project.
 * Browse everything on Wikiversity, or visit a portal corresponding to your educational level: pre-school, primary, secondary, tertiary, non-formal education.
 * Find out about research activities on Wikiversity.

 * Read an introduction for teachers and find out how to write an educational resource for Wikiversity.
 * Give feedback about your initial observations
 * Discuss Wikiversity issues or ask questions at the colloquium.
 * Chat with other Wikiversitans on #wikiversity-en.

And don't forget to explore Wikiversity with the links to your left. Be bold to contribute and to experiment with the sandbox or your userpage, and see you around Wikiversity! --JWSchmidt 13:53, 9 September 2008 (UTC)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: User talk:Eml4500.f08.wiki1.handy


text:
Plant tissue culture/Lab

Welcome to the plant tissue culture laboratory! Here we want users to try to become a researcher. You can understand it like a game of to be a researcher. Just discover tissue culture articles on English Wikipedia and come up with a research scope.

Available samples
''The following are free samples for your research project. If you are interested in researching them go to Project competition''
 * no.95 Codonopsis pillosula
 * This C. pillosula was placed on filter paper February 28, 2008 in aseptic condition. It is regullary feed by 1 ml 0.5xMSliq pH = 4.23 before autoclaving. More about.--Juan 14:18, 9 September 2008 (UTC)

 * several seeds of Codonopsis pillosula
 * seeds were harvested last year and they are available for tests.--Juan 14:18, 9 September 2008 (UTC)

Participants
If you are interested in participating, write down your name:

Research groups
''Please add the name of your research group, placing it as a subpage to PTCL. Plant tissue culture lab/Name of the research group:''
 * … Gautam Borkar
 * ...ekatha gowda

Project competition
''Because of low number of samples people interested in doing research propose their project. It can be done by individuals of research groups. Place dawn you draft as a subpage of PTCL - write a summary of 150-400 words. Tell us the scope of the research and time, you in which you would like to complete it.''

Ongoing projects
The samples which are in this section might be investigated by other researchers or groups if the current unit will agree.

title: Plant tissue culture/Lab


text:
User:Eml 4500.f08.delta 6.specht/HW1

=Homework Assignment 1=

MATLAB
MATLAB Primer, Third Edition Kermit Sigmon Department of Mathematics University of Florida

Section 1: Accessing Matlab
Once logged into the system being used, Matlab can be entered and exited using the matlab and quit system commands. When using certain systems, such as Unix systems and MS Windows, it is suggested that the user keep both the Matlab and local editor active.

Section 2: Entering Matrices
Matlab is a matrix manipulator. Matrices can be 1x1 matrices, scalars, matrices with one column or one row, vectors, or any variation of columns and rows. The inputs can be integers, variables or complex numbers.

Inputting matrices into Matlab can be done in many different ways. They can be input with an explicit list of elements, built in statements or functions, diskfile from local editor or from external data files or applications.

The following are examples of matrix inputs.

Complex Numbers can be put into matrices in the following ways.

If an external data file is used. The file can be loaded into Matlab using the load function. For example, if the file is named data.ext. The file can be uploaded into Matlab using the function load data.ext.

There are many built in function in Matlab that can be used to generate matrices. This section will look at three common matrix generators, rand, magic and hilb.

rand(n) generates a matrix with random entries between 0 and 1 into a nxn matrix. rand(m,n) generates a matrix with rando0m entries between 0 and 1 into an mxn matrix Below is an example of the rand function.

magic(n) will create an integral nxn matrix which is a magic square. This means that the rows, columns and diagonals have common sums. The following is an example of the magic(n) function.

hilb(n) will create a nxn hilbert matrix (m and n denote positive integers).

The following is an example of the hilb(n) function.

Matrix and vector entries can be referenced using A(3,2). This pulls the entry from the 3rd row and the 2nd column from matrix A.

The following is an example of how to reference an entry within a matrix.

Section 3: Matrix Operation, Array Operations
Section three references the basic matrix operators. These operators are addition,+, subtraction,-, Multiplication,*, power,^, transpose,', and left and right division,/ and \. These operators should be known by anyone with a programming background.

While using the multiplication, power and division operators, a period can be used that will make the operators operate entry-wise.

The following is an example of entry-wise operations.

Section 4: Statements, Expressions and Variables; Saving a Session
Matlab is an expression language. It evaluates and interprets expressions entered and produces matrices. Expressions are composed of operators, functions and variable names.

A Statement is normally terminated with the return button. Several statemnet can be place on the same line using commas or semicolons following the statements. Semicolons suppress the printing of the statement.

A session can be saved be using the save command and reloaded using the load command. The following are examples of the save and load commands. EDU>> save

Saving to: matlab.mat

EDU>> load

Loading from: matlab.mat

Section 5: Matrix Building Functions
This section references convenient matrix building functions.

The eye function give an identity matrix of a given matrix. The following is an example of the eye functiion. This example shows the identity matrix of matrix A. EDU>> eye(size(A))

ans =

1    0

0    1

The zeros function gives a matrix of zeros. The following is an example of the zero function.

EDU>> zeros(3,3)

ans =

0    0     0     0     0     0     0     0     0

The diag function creates or extracts diagonals. The following is an example of the diag function.

EDU>> diag(5)

ans =

5

Using two diag functions together a diagonal of a matrix can be retrieved. The following is an example of the diag(diag(A)) function that will retrieve the diagonal of the A matrix.

EDU>> diag(diag(A))

ans =

1.0000 + 5.0000i       0 0            4.0000 + 8.0000i

Matrices can also be built from blocks. The following is an example of a matrix built from matrix A, two zeros matices and one eye matrix. This function builds a 5x5 matrix.

EDU>> B=[A, zeros(3,2); zeros(2,3), eye(2)]

B =

1    0     0     0     0     0     1     0     0     0     0     0     1     0     0     0     0     0     1     0     0     0     0     0     1

Section 6: For, While, and If Statements
The following MATLAB flow control statements operate similarly to most computer languages.

For a given n, the statement below will produce a certain n-vector, which in this case is given a value of 10. EDU>> x=[];

EDU>> for i = 1:10, x=[x,i^2],end

x =

1

x =

1    4

x =

1    4     9

x =

1    4     9    16

x =

1    4     9    16    25

x =

1    4     9    16    25    36

x =

1    4     9    16    25    36    49

x =

1    4     9    16    25    36    49    64

x =

1    4     9    16    25    36    49    64    81

x =

1    4     9    16    25    36    49    64    81   100

The next code produces another n-vector using different parameters.

EDU>> x=[];

EDU>> for i = 1:5

x=[x,i^2]

end

x =

1

x =

1    4

x =

1    4     9

x =

1    4     9    16

x =

1    4     9    16    25

This next code produces the result as above, but in reverse order.

EDU>> x=[];for i = 5:-1:1, x=[x,i^2], end

x =

25

x =

25   16

x =

25   16     9

x =

25   16     9     4

x =

25   16     9     4     1

The statement below will produce the mxn hilbert matrix. For this example, m and n are given a value of 5. This allows for any matrix to be formed, unlike the 1:n statement.

EDU>> for i=1:5

for j= 1:5

H(i,j)=1/(i*j-1);

end

end

EDU>> H

H =

Inf   1.0000    0.5000    0.3333    0.2500

1.0000   0.3333    0.2000    0.1429    0.1111

0.5000   0.2000    0.1250    0.0909    0.0714

0.3333   0.1429    0.0909    0.0667    0.0526

0.2500   0.1111    0.0714    0.0526    0.0417

Once a matrix is defined, the following statements compute the sum of matrix A by adding all of the column sums. The only difference between the two statements are the amount of time taken to complete these computations.

EDU>> A=[1 2 3 4;5 6 7 8]; EDU>> s=0; EDU>> for c=A s=s+sum(c); end EDU>> s

s =

36

EDU>> sum(sum(A))

ans =

36

The next type of MATLAB function is the WHILE statement. For a given number a, the following statement will produce the smallest nonnegative number n such that 2^n>=a.

EDU>> n=0;

EDU>> while 2^n> n

n =

4

The final MATLAB statement is the IF statement. This type of statement will only work if the statement is true. The following example illustrates multiple branching.

EDU>> if n<0

parity = 0;

elseif rem(n,2)==0

parity = 2;

else

parity = 1;

end

EDU>> parity

parity =

2

EDU>> n

n =

4

The remainder function produces the amount left over when using division. The example below shows the remainder of four divided by two.

EDU>> rem(4,2)

ans =

0

This example illustrates the result of using the remainder function without fully completing the argument.

Many relational operators are available for use in MATLAB. A chart has been formed listing the most common operations, and a short description of each.

The following statements are examples of the various relational operators in use. An answer of 1 signifies a true statement, while an answer of 0 illustrates a false statement.

EDU>> 3<5

ans =

1

EDU>> 3>5

ans =

0

EDU>> 3==5

ans =

0

EDU>> 3==3

ans =

1

When applying relational operators to matrices, the true statements are illustrated by a 1 or nonzero. The following examples depict three scenarios of using relational operators on matrices.

EDU>> a=rand(5)

a =

0.0357   0.7431    0.0318    0.6948    0.3816

0.8491   0.3922    0.2769    0.3171    0.7655

0.9340   0.6555    0.0462    0.9502    0.7952

0.6787   0.1712    0.0971    0.0344    0.1869

0.7577   0.7060    0.8235    0.4387    0.4898

EDU>> b=triu(a)

b =

0.0357   0.7431    0.0318    0.6948    0.3816

0   0.3922    0.2769    0.3171    0.7655

0        0    0.0462    0.9502    0.7952

0        0         0    0.0344    0.1869

0        0         0         0    0.4898

EDU>> a==b

ans =

1    1     1     1     1

0    1     1     1     1

0    0     1     1     1

0    0     0     1     1

0    0     0     0     1

Section 7: Scalar Functions
Some functions in MATLAB are scalar in nature, but operate element-wise when used in a matrix. The most common of these functions are found below.

Section 8: Vector Functions
MATLAB functions operate essentially on a vector (row or column). A row by row application can be obtained by using the transpose, i.e. mean(A’)’. As shown the mean(A’)’ function determines the mean of the matrix in a row by row fashion.

EDU>> mean(A')'

ans =

5    5     5

Moreover, to find the maximum entry in a matrix the max(max(A)) function should be used rather than max(A). Here it is shown that the maximum value for the matrix A is equal to 9.

EDU>> max(max(A))

ans =

9

Section 9: Matrix Functions
The matrix functions in MATLAB offer the programs greatest asset. Some of the most useful functions are tabulated below.

Once a matrix is defined, the eig(A) function is used to find the eigenvalues of a given matrix.

EDU>> A

A = 8    1     6

3    5     7

4    9     2

EDU>> eig(A)

ans =

15.0000

4.8990

-4.8990

The [U,D] = eig(A) function, on the other hand, produces a matrix U where each column signifies an eigenvector for matrix A and a matrix D containing the eigenvalues of matrix A along its diagonal. The matrix A that is used for these computations is the same as above. EDU>> [U,D]= eig(A)

U =

-0.5774  -0.8131   -0.3416

-0.5774   0.4714   -0.4714

-0.5774   0.3416    0.8131

D =

15.0000        0         0

0   4.8990         0

0        0   -4.8990

Section 10: Command Line Editing and Recall
MATLAB's line editing and recall are extremely helpful when the related commands are needed repeatedly. These commands are activated by using the arrow keys. Therefore an earlier command can be recalled, edited, and then executed as follows: a=rand(4)

a =

0.7948   0.1730    0.8757    0.8939

0.9568   0.9797    0.7373    0.1991

0.5226   0.2714    0.1365    0.2987

0.8801   0.2523    0.0118    0.6614

Rather than creating an M-file, this convenient feature allows recalling the same command and modifying it before it is executed. In this case the command was modified to generate 9 random numbers instead of the original 3. a=rand(9)

a = 0.2844   0.2259    0.4611    0.0150    0.3200    0.2126    0.4514    0.6124    0.7176

0.4692   0.5798    0.5678    0.7680    0.9601    0.8392    0.0439    0.6085    0.6927

0.0648   0.7604    0.7942    0.9708    0.7266    0.6288    0.0272    0.0158    0.0841

0.9883   0.5298    0.0592    0.9901    0.4120    0.1338    0.3127    0.0164    0.4544

0.5828   0.6405    0.6029    0.7889    0.7446    0.2071    0.0129    0.1901    0.4418

0.4235   0.2091    0.0503    0.4387    0.2679    0.6072    0.3840    0.5869    0.3533

0.5155   0.3798    0.4154    0.4983    0.4399    0.6299    0.6831    0.0576    0.1536

0.3340   0.7833    0.3050    0.2140    0.9334    0.3705    0.0928    0.3676    0.6756

0.4329   0.6808    0.8744    0.6435    0.6833    0.5751    0.0353    0.6315    0.6992

Section 11: Submatrices and Colon Notation
In order to manipulate fairly complex data, vectors and submatrices are often use. The effective use of these diminishes the time length, the number of loops and the quantity of code.

x = [0.0:0.1:2.0]';

y = sin(x);

[x y]

ans =

0        0

0.1000   0.0998

0.2000   0.1987

0.3000   0.2955

0.4000   0.3894

0.5000   0.4794

0.6000   0.5646

0.7000   0.6442

0.8000   0.7174

0.9000   0.7833

1.0000   0.8415

1.1000   0.8912

1.2000   0.9320

1.3000   0.9636

1.4000   0.9854

1.5000   0.9975

1.6000   0.9996

1.7000   0.9917

1.8000   0.9738

1.9000   0.9463

2.0000   0.9093

Colon notation can be used to retrieve submatrices from the main matrix. By using x(1:7,1) the first 7 elements of the matrix will be obtained.

ans =

0

0.1000

0.2000

0.3000

0.4000

0.5000

0.6000

Section 12: M-Files
MATLAB can operate with M-files, which are a set of script files that are executable within MATLAB. The M-file can contain a matrix to be assigned to a certain variable, which is known as a script file. A matrix can be entered into a script file named data.m as follows:

A = [ 1 2 3 4 5 6 7 8 ]; Once the name of the file intended for use is entered into the MATLAB prompt, the assignment will be carried out.

EDU>> data

EDU>> A

A = 1    2     3     4

5    6     7     8

When a long function is intended for use in MATLAB it can also be written as an M-file, which would be called a function file. This allows for editing of the function without having to retype the whole function within the MATLAB prompt. In order to write a function file, the name of the function, and the arguments for the inputs and outputs of the function. Also, any lines of the code that are intended solely for commenting on the intents of the function should have % included at the beginning of the line. This informs MATLAB that the rest of the line does not contain any information necessary to the programs intended computations. Function files would be written as:

function a = randint(m,n) %RANDINT Randomly generated integral matrix. %  randint(m,n) returns an m-by-n such matrix with entries %  between 0 and 9. a=floor(10*rand(4,5));

The same function can be stated more generally.

function a = randint(m,n,a,b) %RANDINT Randomly generated integral matrix. %  randint(m,n) returns an m-by-n suc matrix with entries %  between 0 and 9. %  rand(m,n,a,b) return entries between integers a and b. if nargin < 3, a = 0; b = 9; end a=floor((b-a+1)*rand(3,4)) + a;

The use of the command nargin in this example allows the user to omit values for input variables, and then set them to a default value after using the command. Multiple output variables can also be obtained and equated to a value obtained by a function. An example of this is presented below.

function [mean,stdev]=stat(x) %STAT Mean and standard deviation %  For a vector x, stat(x) returns the mean of x; %   [mean,stdev] = stat(x) both the mean and standard deviation. %  For a matrix x, stat(x) acts columnwise. x=[1 2 3 4]; [m n]=size(x); if m==1 m=n; %handle case of a row vector end mean = sum(x)/m; stdev=sqrt(sum(x.^2)/m-mean.^2);

For this example, the vector x has been declared within the M-file, but it can also be declared within the MATLAB prompt, and then the function can be run without the line declaring x. If this line is left within the function, the value of x would be changed during the function, and the answer obtained may not be correct.

MATLAB can also run more efficiently if the matrix in use is predefined. The matrix, therefore, would not have to be resized every iteration. An example of a for loop that demonstrates this is as follows:

EDU>> M=magic(6);

EDU>> E=zeros(6,50);

EDU>> for j=1:50

E(:,j)=eig(M^i);

end

This function has already declared a size for the matrix E, thus saving MATLAB and the user time that would otherwise be performing calculations.

The next function demonstrates the use of nargin, nargout, and feval. The first two allow some of the input variables and output variables to be optional. The use of feval allows an input variable to be named as a string.

function [b,steps]=bisect(fun,x,tol) %BISECT Zero of a function of one variable via the bisection method. %  bisect(fun,x) returns a zero of the function. fun is a string %  containing the name of a real-valued MATLAB function of a single real %  variable; ordinarily function are defined in M-files. x is a starting %  guess. The value returned is near a point where fun changes sign. For %  example, bisect('sin',3) is pi. Note the quotes around sin. % %  An optional third input argument sets a tolerance for the relative %  accuracy of the result. The default is eps. An optional second output %  argument gives a matrix containing a trace of the steps; the rows are %  of form [c f(c)]. %Initialization fun=0.5; x=[1 2 3 4]; if nargin <3, tol = eps;end trace = (nargout==2); if x~=0, dx = x/20; else, dx=1/20; end a=x-dx; fa=feval(fun,a); b=x+dx; fb=feval(fun,b);

%Find change of sign. while(fa>0)==(fb>0) dx=2.0*dx; a=x-dx;fa=feval(fun,a); if(fa>0)~=(fb>0),break,end b=x+dx; fb=feval(fun,b); end if trace, steps=[a fa;b fb];end

%Main Loop while abs(b-a)>2.0*tol*max(abs(b),1.0) c=a+0.5*(b-a); fc=feval(fun,c); if trace, steps = [steps; [c fc]];end if (fb>0)==(fc>0) b=c;fb=fc; else a=c;fa=fc; end end

Section 13: Text Strings, Error Messages, and Input
A string of text can be written in MATLAB with a set of single quotes. The string can also be equated to a variable:

EDU>> s='This is a test' s =

This is a test

This string would be equated to the variable s, and restated by the program. If desired, the string can be displayed without equating it to any variable by using: EDU>> disp('this message is hereby displayed')

this message is hereby displayed An error message, which will also end the execution of a function, can be displayed within a function by using the code in a manner as follows: EDU>> error('Sorry, the matrix must be symmetric')

??? Sorry, the matrix must be symmetric

An interactive message can also be used in a MATLAB function. This would ask for a value from the user and equate this to a variable, declared by the function. In this case, the variable iter is equated to the input, and the message displayed is contained within single quotes.

EDU>> iter = input('Enter the number of iterations: ')

Enter the number of iterations: 5

iter =

5

Section 14: Managing M-Files
M-files must be stored in a directory that is available to MATLAB, which is termed the working directory. M-files stored in this location are available to be manipulated by MATLAB, including running the program to return a value. While working in MATLAB there are commands that are available to make working with M-files simpler.

Section 15: Comparing Efficiency of Algorithms: flops, tic and toc
Efficiency within MATLAB is determined by using two main values. The first is the number of floating point operations performed (flops). Entering this before and after running a function will return the flop count for the function. The value can also be reset by entering flops(0) immediately before running the function. If the user is working in MATLAB Version 6 or later, this command is not available. The commands tic and toc, when used immediately before and after executing a statement, will return the amount of time elapsed while performing the operation. Two statements that perform the same operation are shown below, along with the elapsed time.

EDU>> A=[1 2;3 4]

A = 1    2

3    4

EDU>> b=eye(2)

b =

1    0

0    1 EDU>> tic,x=A\b;toc

Elapsed time is 0.048711 seconds.

EDU>> tic, x=inv(A)*b; toc

Elapsed time is 0.266468 seconds.

From this it can be seen that although the results of the two functions are the same, by adding the inverse function to the second declaration, more time is needed to perform the same calculation.

Section 16: Output Format
All computations in MATLAB are executed while maintaining double type precision. The output format can be changed by using the following functions, and will remain in this format until changed by the user.

Section 17: Hardcopy
If a copy of the commands and the results are needed, MATLAB can write these to a file, excluding any graphics that are obtained. By using the command diary followed by the filename that results are to be written to, this action can be initiated. This can be turned on and off by using the commands diary on and diary off.

Section 18: Graphics
Below is the basic list of commands for displaying a graph in MATLAB.

A sine command is being used below to show the use of the command plot(x,y). This is drawn over the interval -4 to 4. The input used in MATLAB is displayed first, followed by the plot that is displayed in a separate window.

EDU>> x=-4:.01:4; y=sin(x); plot(x,y)

The table given below shows many commands that can be used to manipulate aspects of the graph, including the titles and the axes. It should be noted that any command consisting of the prefix axis should be stated after the plot command.

The command fplot is used as a demonstration below. The interval that is to be graphed is displayed in the matrix. The m-file that contains the computations is listed first, followed by the command in the MATLAB prompt.

function y=expnormal(x) y=exp(-x.^2);

fplot('expnormal',[-1.5,1.5])

A set of parametrically designed curves can be displayed on the same graph with a set of commands that are similar to those shown below.

t=0:.001:2*pi; x=cos(3*t); y=sin(2*t); plot(x,y)

The following two sets of commands produce the same graph. Both are manners in which multiple plots can be displayed on the same graph. The first declares each variable individually. The second example inputs each of the Y variables in a matrix form.

x=0:.01:2*pi;y1=sin(x);y2=sin(2*x);y3=sin(4*x);plot(x,y1,x,y2,x,y3)

x=0:.01:2*pi;Y=[sin(x)', sin(2*x)', sin(4*x)'];plot(x,Y)

Linetypes and the colors of the lines can also be changed. The commands for these are listed in a table.

Commands such as those shown in the table above can be applied in a manner as follows:

x=0:.01:2*pi; y1=sin(x);  y2=sin(2*x);  y3=sin(4*x);

plot(x,y1,'--',x,y2,':',x,y3,'+')

MATLAB provides a set of commands in order to print graphs without leaving the command prompt. Some of these basic commands are listed in the table shown below.

Three dimensional plots can be generated in a manner similar to the x-y plots generated earlier. t=.01:.01:20*pi; x=cos(t);  y=sin(t);  z=t.^3;plot3(x,y,z)

A mesh plot can be created by using the command mesh, as shown in the table at the beginning of this section. An identity matrix is used to display this command. mesh(eye(10))

A surface plot similar to the mesh plot above is shown below. surf(eye(10))

A meshgrid can be created using the command meshgrid. The following set of code creates a matrix x which have rows that equal xx and has a column length of yy, as well as a matrix y which has columns that equal yy and has a row length of xx. These values are then used to evaluate a chosen function, in this case being the exponential function. The same code could also be written in a shorter form, which immediately follows the first set of code. xx=-2:0.2:2;

yy=xx;

[x,y]=meshgrid(xx,yy);

z=exp(-x.^2 - y.^2);

mesh(z)

[x,y]=meshgrid(-2:.2:2, -2:.2:2);

z=exp(-x.^2 - y.^2);

surf(z)

The set of commands used to edit axes and titles that were presented for planar plots are also applicable for all of the three dimensional plots that have been presented.

The use of one of these commands is demonstrated below to demonstrate how it is declared. colormap(cool)

Some surface plots are already programmed into MATLAB, and are easily plotted. These include sphere, cylinder, and torus. An m-file used to generate a torus plot is shown below, followed by the plot that is generated. function [x,y,z]=torus(r,n,a) %TORUS Generate a torus %  torus(r,n,a) generates a plot of a torus with central radius a and %  lateral radius r.  n controls the number of facets on the surface. %  These input variables are optional with defaults r=0.5, n=30, a=1. % %  [x,y,z] = torus(r,n,a) generates three (n+1)-by(n+1) matrices so that %  surf(x,y,z) will produce the torus. % %  See also SPHERE, CYLINDER

if nargin <3, a=1; end if nargin <2, n=30; end if nargin <1, r=0.5; end theta = pi*(0:2:2*n)/n; phi = 2*pi*(0:2:n)'/n; xx=(a + r*cos(phi))*cos(theta); yy=(a + r*cos(phi))*sin(theta); zz=r*sin(phi)*ones(size(theta)); if nargout ==0 surf(xx,yy,zz) ar = (a+r)/sqrt(2); axis([-ar,ar,-ar,ar,-ar,ar]) else x=xx;y=yy;z=zz; end

Section 19: Sparse Matrix Computations
A sparse matrix can be used to increase efficiency and storage space by storing only the nonzero elements that are contained within the matrix. Some of the commands to manipulate matrices in this manner are listed below.

A full tridiagonal matrix is created below, and then converted to sparse mode.

EDU>> F=floor(10*rand(6));F=triu(tril(F,1),-1)

F =

8    2     0     0     0     0     9     5     4     0     0     0     0     9     8     6     0     0     0     0     1     0     3     0     0     0     0     8     6     0     0     0     0     0     1     8

EDU>> S= sparse(F)

S =

(1,1)       7

(2,1)       2

(1,2)       5

(2,2)       1

(3,2)       1

(2,3)       2

(3,3)       9

(4,3)       3

(3,4)       3

(4,4)       8

(5,4)       5

(4,5)       7

(5,5)       3

(6,5)       5

(5,6)       9

(6,6)       1

Another example of a sparse matrix is shown below.

EDU>> m=6;n=6;e=ones(n,1);d=-2*e;

EDU>> T=spdiags([e,d,e],[-1,0,1],m,n)

T =

(1,1)      -2

(2,1)       1

(1,2)       1

(2,2)      -2

(3,2)       1

(2,3)       1

(3,3)      -2

(4,3)       1

(3,4)       1

(4,4)      -2

(5,4)       1

(4,5)       1

(5,5)      -2

(6,5)       1

(5,6)       1

(6,6)      -2

Another example of a matrix in this same format is shown below. The full matrix is shown afterwards. The difference between the two is the values of m and n that are input into the function.

EDU>> T=spdiags([e,d,e],[-3,0,2],m,n)

T =

(1,1)      -2

(4,1)       1

(2,2)      -2

(5,2)       1

(1,3)       1

(3,3)      -2

(6,3)       1

(2,4)       1

(4,4)      -2

(3,5)       1

(5,5)      -2

(4,6)       1

(6,6)      -2

EDU>> S=full(T)

S =

-2    0     1     0     0     0

0   -2     0     1     0     0

0    0    -2     0     1     0

1    0     0    -2     0     1

0    1     0     0    -2     0

0    0     1     0     0    -2

A sparse matrix can also be entered by including only the nonzero entries by using code that resembles the following:

EDU>> i=[1 2 3 4 4 4];j=[1 2 3 1 2 3]; s=[5 6 7 8 9 10];

EDU>> S=sparse(i,j,s,4,3),full(S)

S =

(1,1)       5

(4,1)       8

(2,2)       6

(4,2)       9

(3,3)       7

(4,3)      10

ans =

5    0     0

0    6     0

0    0     7

8    9    10

In the commands above, the matrix s gives all the nonzero values contained in the matrix, while the matrices i and j give their row and column values respectively.

Another method of forming a sparse matrix is shown below. In this instance the matrix is constructed using two variables to declare the size of the matrix.

EDU>> n=6;e= floor(10*rand(n-1,1));E=sparse(2:n,1:n-1,e,n,n)

E =

(2,1)       5

(3,2)       4

(5,4)       3

(6,5)       1

The amount of time that an operation takes to compute can be compared for the situations when the matrix is sparse (S) or full (F). This can be used to compare for efficiency purposes. The matrices are constructed once again from variables that are declared in the prompt. The output that follows is labeled sparsetime and fulltime, which are equal to the time taken to complete each operation.

EDU>> n=20;e=ones(n,1);d=-2*e; T=spdiags([e,d,e],[-1,0,1],n,n);A=full(T);

EDU>> b=ones(n,1);s=sparse(b);tic,T\s;sparsetime=toc, tic,A\b;fulltime=toc

sparsetime =

0.0134

fulltime =

0.0809

Other operations that can take place by using sparse (S) or full (F) matrices are listed in the table below.

Eig(S) can also be used to manipulate a sparse matrix, but only if the matrix is symmetric. If it is not symmetric, then this command will return that the computation is undefined.

History

 * Wikipedia was launched in 2001 by Jimmy Wales and Larry Sanger
 * The name Wikipedia breaks down into "wiki" (a collaboration of websites) and encyclopedia
 * The purpose of Wikipedia is to collect and summarize all human knowledge in every major language
 * All members of society can contribute to Wikipedia

Creating an Account
1. In order to create an account, the user must first choose a major language 2. The user must then click on the log in/ create account link in the upper right hand corner 3. If the user does not have an existing account they should click on the create one link 4. The user must enter the word(s) in the given text box that appears in order to protect against automated account creation 5. Next, the user must fill the appropriate information such as user name, password, and an e-mail address which is optional
 * Once the account is created the user may give his/her contribution by writing their own wiki-articles or by editing the articles of other users
 * All edits to wiki-articles are permanently recorded in archives, and publicly visible in the history link of any page *(The Wikipedia contribution system is a great asset yet its own greatest flaw)

Criticism

 * Wikipedia allows its users to edit each others pages which brings a mutual responsibility to all users not to abuse the right to edit. The open nature of the system to many critics make it unreliable as a reference. On top of unreliability, the system allows for strongly opinionated editors to attempt to dominate articles. Exposure to vandalism by users who edit articles is also a critical argument against Wikipedia. Wikipedia vandalism ranges from page lengthening, blanking, spamming, user name vandalism, etc.

Vision

 * Media Wiki is an important program in that it allows its users to collaborate each others work.
 * The course will employ the Wikiversity tool. This will allow the students, professor, and teaching assistants to communicate with ease and to review each team's work so as to maximize the learning experience during the semester.
 * MIT's Open Course Wear is a prime example of knowledge shearing that is Wiki-like in that MIT students only, since access faculty is not provided, can share information with each other about their course work. MIT's OCW has proven to be a very powerful tool for students campus-wide.

Method of Work
Course Website: EML4500

 * Teams consist of six members that share the course workload. One member will be selected as the team leader. Each of the six members will complete parts of the homework assignments. Then, the team leader will compile the information into one article. That final article will be graded by the teaching assistant and assigned a grade.
 * Each member of the team receives the grade that is assigned. Team members will evaluate each others contribution and effort at each exam by giving an evaluation score based on a scale ranging from one to eight.

E-Learning

 * This tool is not like MediaWiki since it does not allow for collaboration between team members, teams, and the professor. However, E-Learning excels in passing announcements from professor to students.

Old Approach/New Approach

 * Prior to using the Wikipedia/Wikiversity system, professor Dr. L. Vu-Quoc taught EML4500: Finite Element Analysis based on a system where homework criteria accounted for 10% of a students final grade. The other 90% of the grade was based on 3 exams, each worth 30%.
 * Dr. L. Vu-Quoc's new approach allows for a greater emphasis on the students homework contribution. The Wikipedia/Wikiversity system of posting class notes/homework problems keeps students more involved and also allows other fellow classmates to benefit from having access to this information. Hopefully, in the near future students will be able to save money by not having to purchase expensive course text books. The new approach weighs a students homework criteria at 30% while 3 exams (equal in worth) make up the remainding 70%.

Trusses
Trusses are commonly known as structural members that resist axial forces. In order to facilitate the analysis of simple truss systems the matrix method should be utilized.

Matrix Method
The matrix method provides basic steps that are use as a recipe while solving truss systems helping solve problems more efficiently. This is achieved because a common labeling system for the diagrams is used.

Notation

Consider a truss system with two elastic bars, meaning that they are deformable since no materials are perfectly rigid, and both supported ends fixed and constrained to zero displacement in the x and y, as well as the x̃ and ỹ directions. Additionally, a force P loads the truss at the vertex.

Notice the global picture of the above truss system. It is composed of two bar elements that are joined and fixed at both ends. This calls for the need to identify three global nodes, and their reactions; it has been chosen from this point forth to circle the global node numbers for easy notation. Developing a free-body diagram (fbd) will result in the analysis above for the whole truss system (global picture).

We will analyze this system by choosing to use the y-x coordinate system. This global fbd yields 4 unknowns and 3 equations, making this system statically indeterminate. However, we can separate each bar element and build its own fbd.

New notation had to be used to number the bar element number with numbers inside a triangle. The diagram above is, thus, for bar element number 1. Also, local notation for element nodes have also been identified with a square around its node number, each corresponding to a global node (circled). Forces and reactions at each node have also been shown. The x and y directions of the reactions at the supports have also been separated, These have been labeled with an R with a subscript and a superscript that reflect the degree of freedom and the element number, respectively. The labeling of these forces is governed by these rules, in order: The directions of displacement of each node can also be represented by the red arrows in the diagram above, and both represent the degrees of freedom of the element. To save time, it has been decided to also label these arrows as being the direction of movement, each serving a dual purpose. The distances are represented by a d with the labels being the same for its force counterpart. We have done the same for the second bar element as for element 1, shown in the figure below.
 * Follow the order of the global node number
 * For each global node number, label the x-direction reaction first, then the y-direction reaction.

Notice that the number in the triangle has been changed to 2 to represent the element number. Also, the rules described above to label nodes has been followed. Global node 2 (circled) is now local node 1 (in square) and the global node 3 is now the local node 2. There is also another choice of local node numbering, where global node 2 can be local node 2 and the global node 3 is the local node 1. Both modes of numbering will yield the same outcome once the problem is solved, and the second is illustrated below.

Force-Displacement Relation

Recall a 1-D spring:

The above model is for a 1-D spring element with one end fixed. The following force-displacement (FD) relationship for this element is described below.

 * $$f=k*d$$

Where $$f$$ is the force on the free end, $$d$$ the distance the spring is deformed because of the force, and $$k$$ the stiffness of the spring and it depends on the material the spring is made out of.

If we were to free the left end of the above spring then the spring would be affects by the FD relationship as seen below.

The FD relation for this element is more complex as the displacements depend on each other, and each depends on both forces. We model this relationship with the aid of matrices, where each term is represented by a matrix.

 * $$\begin{pmatrix}

f_1\\ f_2\end{pmatrix}$$ = $$\begin{bmatrix} k & -k\\ -k & k\end{bmatrix}$$ $$\begin{pmatrix} d_1\\ d_2\end{pmatrix}$$

The first is a 2x1 column matrix that represents the forces on the spring, the second is a 2x2 matrix that represents the stiffness of the spring, and the third is also a 2x1 column matrix that represents the displacements of both free ends or nodes. This matrix equation is product of two cases that superimpose, each representing the behavior of both nodes as the spring stretches or compresses.

 * Case 1: The observer sits on node 1 and watches how the spring stretches out, represented by:
 * $$f_2=k(d_2-d_1)$$

 * Case 2: The observer sits on node 2 and watches how the spring stretches out, represented by:
 * $$f_1=k(d_1-d_2)=-f_2=-k(d_2-d_1)$$

Steps for Solving Truss Systems

 * 1) Global picture.
 * 2) Element picture.
 * 3) Global Free Diagram.
 * 4) Elimination of known degrees of freedom.
 * 5) Computation of element forces.
 * 6) Computation of reactions.

Global Picture
The global picture is the description of the system as one entity. This diagram includes known reactions such as applied forces, fixed degrees of freedom (dofs), and constrains. The global picture also illustrates the unknown part of the system, the reactions.

 * Redraw the truss system.
 * Label the global nodes.
 * Label the global forces.

Element Picture
The element picture is the description of each element forming the whole structure. In this diagram the known internal forces and reactions that are acting on that element are illustrated.

 * Redraw the truss system by parts.
 * Label the element degrees of freedom (dofs).
 * Label the element forces.

Note: The element dofs and forces can be either placed in the global coordinate systems or in the local coordinate system.

Global Free Diagram Relation
In order to apply the matrix method it is necessary to develop a relationship between the applied forces and the resulting displacement. The relationship can be formed by treating the trusses as deforming springs and using the mass-spring principle. The mass-spring principle is defined by the equation F=Kd, where F is the force matrix (n x 1), d  is the displacement matrix (n x 1), and K is the spring constant matrix (n x n). Where n is the number of unknown and known displacement degrees of freedom (dofs). These matrices define the linear relationship between the element forces and the element stiffness matrix.

Elimination of known degrees of freedom
It is necessary to reduce the global free body diagram relation in order to solve the stiffness matrix. Due to the non-singularity of the stiffness matrix the mass-spring principle equation is invertible. Resulting in the following new relationship: d = K-1F, where d  is the displacement matrix (m x 1), K-1 is the spring constant matrix (m x m), and F  is the force matrix (m x 1). Where m is the number of unknown displacement degrees of freedom (dofs).

Computation of element forces
As a result of now knowing the displacement matrix d , the element forces can be calculated.

Computation of reactions
The last step is the computation of reactions of the unknown forces in the truss system. Since d and F have the same matrix size the matrix K is symmetric. By counting the support’s constrains the unknowns can be solved by using a system of linear equations.

Contributing Team Members
Iain Specht Eml_4500.f08.delta_6.specht September 20, 2008 Diana Guzman eml4500.f08.delta_6.guzman September 20, 2008 Nicolas Castrillon eml4500.f08.delta_6.castrillon September 20, 2008 Sean Lopezeml4500.f08.delta_6.lopez September 20, 2008 Eric Ramirez eml4500.f08.delta_6.ramirez September 20, 2008 Trent Kruegereml4500.f08.delta_6.krueger September 20, 2008

title: User:Eml 4500.f08.delta 6.specht/HW1


text:
Plant tissue culture/no.95 Codonopsis pillosula

This is a page of a sample no. 95. There are available these data:


text:
User talk:Eml4500.f08.team.dwyer.jd

Welcome to Wikiversity
 Hello Eml4500.f08.team.dwyer.jd, and welcome to Wikiversity! If you need help, feel free to visit my talk page, or contact us and ask questions. After you leave a comment on a talk page, remember to sign and date; it helps everyone follow the threads of the discussion. The signature icon in the edit window makes it simple. To get started, you may

 * Take a guided tour and learn to edit.
 * Visit a (kind of) random random project.
 * Browse everything on Wikiversity, or visit a portal corresponding to your educational level: pre-school, primary, secondary, tertiary, non-formal education.
 * Find out about research activities on Wikiversity.

 * Read an introduction for teachers and find out how to write an educational resource for Wikiversity.
 * Give feedback about your initial observations
 * Discuss Wikiversity issues or ask questions at the colloquium.
 * Chat with other Wikiversitans on #wikiversity-en.

And don't forget to explore Wikiversity with the links to your left. Be bold to contribute and to experiment with the sandbox or your userpage, and see you around Wikiversity! --JWSchmidt 15:49, 9 September 2008 (UTC)

First Warning
All uploads you have made on the wikiversity does not license. Note that this is prohibited by the rules of the wikiversity. All images must have a license, and over a license compatible with the licensing of projects of the Wikimedia Foundation. If you continue as follows:
 * All the images you've uploaded will be erased
 * You may suffer a ban on changes in the pages of wikiversity (Prohibition in writing).

Best regards. Crochet.david 18:54, 7 November 2008 (UTC)

title: User talk:Eml4500.f08.team.dwyer.jd


text:
Banking education

The "banking" concept of education was a key educational theory critique by libertarian Brazilian educator Paulo Freire (in particularly, see Paulo Freire) and refers to educational models and practice whereby students are assumed to be empty vaults into which educators deposit knowledge.

title: Banking education