text:
Portal:Social entrepreneurship/community mobilisation/Questionnaire

The level of participation in the curriculum development process was lower than hoped.

This page is to design a survey to explore reasons and ways of growing the community of social entrepreneurship curriculum developers (etc.).

For now, just dump possible questions for refinement later.

=Questions for the Survey=

Rate the following statements from 1 - 5 where 5 means "this applies to me 100%" and 1 means "not applicable at all":

 * I don't have time to contribute meaningfully.
 * The timing is wrong. Curriculum development is done at a different time of year in our institution.
 * The topic is not directly relevant to my other work activities.
 * This seems to be duplication of other initiatives such as SBL and/or CBL.
 * I already subscribe to at least one other mailing list concerned with social entrepreneurship.
 * Lack of knowledge and insight about OER and the opportunity peer production presents.
 * Lack of confidence of my knowledge of the field and ability to contribute.
 * Hesitant to write anything in case the quality is not good enough.
 * The wiki approach of continuous peer review is intimidating.
 * Institutional policy disallows me to share knowledge in this way.
 * Using the wiki is difficult and I do not have time to learn how.

 * is social entrepreneurship an area that responds to your needs and interests?
 * has this network benefitted your work?
 * what will improve the value of the network? More individuals, more weekly communication, more opportunities for face to face meeting, more content on wiki, formal structure for network, other
 * did you make a useful connection and collaborate with someone through this network?
 * should this network continue?
 * how often do you visit the wiki? Once a day, once a week, once every two weeks, once a month, never
 * does the content and curriculum on the wiki respond to your needs?
 * few people contributed content to the wiki. Is this because:
 * the technology is difficult,
 * there is no time,
 * you have no material to contribute,
 * you are not interested in theme,
 * other

 * It might make sense to make a separate survey page and discuss that. Ktucker 21:29, 18 September 2008 (UTC)


text:
User:Devourer09/PLE

This is my PLE or Personal Learning Environment. This is the space that I'll use to help me use Wikiversity to learn and create resources. It will also be useful for collecting my thoughts.

Learning topics
These topics below are topics I wish to learn more about.

 * School:Automobile maintenance - Could potentially become a very informative resource.
 * http://www.youtube.com/watch?v=dQnx2qDrB78&feature=related
 * https://bugs.webkit.org/show_bug.cgi?id=28328 breaks Twinkle. :(
 * http://meta.wikimedia.org/wiki/Help:Unified_login
 * http://en.wikipedia.org/wiki/User:SheffieldSteel/Pigs
 * Make a sudoku implementation
 * Find that song by ABBA that features rap type vocals.
 * Figure out which movie I saw William H. Macy as the leader actor in. It was a drama on TV where he leaves his wife and tries to pay for sex.
 * PUA stuff, get jewelry for peacocking from Sears
 * Nutrition
 * Fitness
 * College classes
 * Wiki editing
 * Using Inkscape to make diagrams for learning projects.
 * Typing lesson.
 * Elementary typing
 * Mercurial
 * Bazaar
 * Ubuntu
 * IRC
 * PyPy
 * RPython
 * Create software together. Create a source code repository, possibly to help learn about CVS, SVN, Mercurial, Bazaar, Git, etc... Using the sandbox server.
 * Better way to manage talk pages and discussions between people.
 * Why use a bugtracker as a feature request submission tool?
 * Priority list to organize my time, what I should focus on that will help me accomplish these goals faster.
 * Completion status boxes, perhaps form a team to go around marking projects with how complete they are. Should learn to know how to use them also.
 * Wikiversity organization idea involving the Portal and Topic namespace and their purpose. And I'm not even sure if Topic should be a necessary namespace, if Portal could just encompass all tasks that Topic has. I guess it can't. There could be a Portal:Python and a Topic:Python, where Topic:Python is more about the language itself and nothing but itself, and Portal:Python would be all topics that involve Python.

Computer
How to use a computer effectively, like, understanding what an operating system is, what a web browser is, what software is, what the internet is.

 * Computer literacy
 * Introduction to Computers

 * Operating system
 * Browser

Operating Systems

 * Linux
 * Google Chrome OS

Programming

 * Python, comprehensive course on learning Python, and then
 * Python learning resources
 * Python
 * Topic:Python
 * Vim
 * Introduction to Programming
 * Topic:Computer programming
 * Interesting Python code snippet http://shlomme.diotavelli.net/2008/05/05/look-at-me-i-know-functional-programming/

MediaWiki
Learn wikimarkup.

 * Help:Editing
 * w:Help:A quick guide to templates
 * m:Help:DPL
 * m:Help:Editor
 * m:Help:Interwiki linking
 * m:Help:HTML in wikitext
 * User infobox template that keeps the userpage clean.

Wikipedia

 * http://en.wikipedia.org/wiki/User:WBOSITG/Virtual_classroom
 * Edit summary legend

Wikiversity

 * Understand how Wikiversity is organized.
 * Community projects
 * Introduction for Wikiversity teachers on how to create learning resources.
 * What is the difference between learning resources, materials, and projects?
 * Learn to create template documentation like on WP
 * Template:Using Wikiversity many useful links.
 * Namespaces

Wiki's

 * How to make a wiki
 * Use Python. ;P
 * Probably need something like SQLite also.
 * Personal wiki
 * TiddlyWiki and perhaps DokuWiki
 * MoinMoin looks nice. Written in Python. :)

Writing

 * Removing fluff from writing

Projects
This is a list of things I am going to do on Wikiversity or other Wikimedia projects.

Navigating Wikiversity
User:Devourer09/Navigating Wikiversity

Wikiversity resources

 * Figure out a template/redirect to show that this IP address is mine.
 * Try and understand what all the fuss is about for JWS on Community Review/JWSchmidt 2010

IDE
It'd be nice to have an IDE that is similar to PIDA. Possibly even create a Python port of Vim. All using Pyjamas.

TODO

 * 1) Create editor first. Probably something based on Vim. Perhaps even rewrite Vim in Python. It'd be cool to have a vimscript to python translator.
 * 2) FIXME Add other features... Probably other views, such as an updated view for editing wikipages. Should make this more specific. FIXME lol.

Uses

 * Editing wiki's. Perhaps have a viewer that updates to reflect changes in the buffer.
 * Nice to integrate a debugger.
 * Easy way to create projects and build and compile them.
 * Drag and drop GUI designer.

Physical fitness
This will be the section where I'll keep track of my physical fitness objectives and accomplishments. My main objective right now is to put on more muscle mass.

Workout regimen

 * 1) Upper body: triceps, lats, biceps
 * 2) Middle: chest, abs, side abs, back
 * 3) Lower body: glutes, quads, inward hip flexors, outward hip flexors, hamstrings

Nutritional diet

 * Quinoa
 * Grapenuts cereal
 * Garden rotini pasta

StarCraft II
Google Squared grid of StarCraft II units. It's not complete and quite inaccurate. If it was more accurate it would be a very handy tool.

Employment

 * User:Devourer09/Employment subpage to create some learning resource material and organize my employment endeavors.

College education

 * Re-applying at NCTC
 * NCTC summer semester 2011 admission and registration instructions
 * NCTC eLearning FAQs

Wikipedia

 * Requested articles that I could create to enhance my skills as a WP editor.

Cool WV pages

 * Social psychology (psychology)/Participants - Study this to learn from the nice organization.
 * User:Erkan Yilmaz/PLE - Maybe I can learn something from how he uses his PLE.
 * School:Game design - Study this to get ideas on how to organize perhaps a portal.

Subpages

 * User:Devourer09/sandbox
 * User:Devourer09/Useful templates
 * User:Devourer09/Ideas for organizing Wikiversity
 * User:Devourer09/Mentor box

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

title: User:Devourer09/PLE


title: File:Statics1.JPG


text:
User:Eml4500.f08.bottle.loschak/HW1

Output Format
Using the format command the user can change the format of the displayed output. Here are some choices with data from the help command:

Hardcopy
In order to obtain a hardcopy one's work, the easiest command to use is diary filename. This will begin writing everything that appears on the screen until the command diary off is entered. The command diary on will resume writing. This file can be viewed later and printed. The diary command will not record graphics.

Graphics
A user can plot different types of graphs using the primary commands plot, plot3, mesh, and surf. The plot command is used for creating linear x-y plots, such as a sine curve or an exponential. To graph a sine wave from -pi to pi a user can enter the following command: x = -pi:.01:pi; y = sin(x); plot(x,y) It is possible to plot multiple curves on the same graph by adding more arguments into the parentheses, like so: x = -pi:.01:pi; y1 = sin(x); y2=cos(x); plot(x,y1,x,y2) Changing the color and linetype of the lines being plotted is also possible by adding arguments into the plot command. For example: x = -pi:.01:pi; y1 = sin(x); y2=cos(x); plot(x,y1,'b--',x,y2,'y:') Will produce a sine curve with a blue dashed line and a cosine curve with a yellow dotted line. Graphs can be labeled by the following commands: The hold command will allow the next plot to be superimposed on top of the old plot until the command "hold off" is used. To save a graph the command print filename is useful. It will automatically save as a *.ps PostScript file unless a file extension is specified. Adding to the command, print -append filename, one can add multiple images to the same image file. A 3-D line plot can be displayed with the command plot3(x,y,z) by including 3 vectors of the same size. A mesh plot or a surface plot can be displayed with the commands mesh(x) or surf(x). Shading on surfaces can be controlled with the "shading" command. The commands "set(1)" and "gca,set(ans)" can be used to control properties of graphs.

Sparse Matrix Computations
In the event that a user must perform many calculations with matrices containing a large amount of zeros, the "sparse" command can be used to ignore the zeros and save time and storage space. With matrix B containing a large amount of zeros, matrix S can save space by entering the command S = sparse(B). The process can be reversed by entering the command B=full(S). The function spdiags can create a sparse banded matrix by specifying diagonals.

title: User:Eml4500.f08.bottle.loschak/HW1


text:
User:Eml4500.f08.bottle.loschak/HW2

HW 2
9/17 Once we have used the boundary conditions (global nodes 1 and 3 are fixed) to eliminate the 1st, 2nd, 5th, and 6th columns of the global K matrix, we are left with the matrix below.

 * $$\begin{bmatrix} K_{13}&K_{14}\\ K_{23}&K_{24}\\ K_{33}&K_{34}\\ K_{43}&K_{44}\\ K_{53}&K_{54}\\ K_{63}&K_{64} \end{bmatrix} = \begin{Bmatrix} d_3\\ d_4 \end{Bmatrix} =\overline{F}_{6x1}$$

We can also delete the 1st, 2nd, 5th, and 6th rows in the global K matrix and in the global F (force) matrix. The global F matrix will be a 2x1 matrix containing the values F3, F4. If we recall from the original problem statement that the force P acting on the truss system is directed upwards in the y-direction, we can say that F3=0 and F4=P.

Here are the resulting force displacement reactions.

Our problem is now reduced to a much more manageable matrix. Since we already know the values of F, we want to solve for the global displacement d3 and d4 terms. We will take the inverse of the 2x2 K matrix in order to do this.

The resulting global displacements d3=4.352 and d4=6.1271 are the displacements in the x- and y-direction of global node 2.

To compute the reaction forces in each individual element we solve the matrices k(e)d(e) = f(e) for e = 1,2 Recall that in element 1 the displacement terms d3 and d4 are in the 3rd and 4th rows. It is important here to note that the displacements terms are in different rows for each element. The local displacement matrices are below.

9/19 Due to the fact that the local displacement matrix for element (1) has zeros in the first two rows, the first two columns of the local k matrix can be deleted. Plugging in numbers for the matrix k(1)d(1) = f(1) We get the local reaction forces for element (1) below. Since we know that element (1) is in equilibrium, the following three equations are true Element (2) can be represented by the following diagram with these forces acting. Taking the room sum squares of the local force components will help solve for the magnitude of forces P for both elements. There are two methods of statics to solve for the 2-bar truss system. These two principles describe the Euler Cut Principle.

title: User:Eml4500.f08.bottle.loschak/HW2


title: File:Statics2.JPG


text:
University of Florida/Eml4500/f08.qwiki.bishop/MATLAB

Link to MATLAB Primer: http://apollo.mae.ufl.edu/~vql/courses/feem/matlab_primer_3rd.pdf

Accessing MATLAB
Almost all versions of MATLAB include an icon on the desktop in which you can open MATLAB. Also there is the option of going through the start menu. While in MATLAB, to exit the command is quit or exit.

Entering Matrices
In MATLAB, all entries are treated as a matrix. They can be only a 1x1 matrix, up to nxn matrices, where n is an integer. Scalars are considered 1x1 matrices and vectors are either 1 row or 1 column matrices.

There are multiple ways to write matrices in MATLAB. The following are two different codes for producing matrix A.

Input: A = [1 2 3; 4 5 6; 7 8 9] Output: A = 1    2     3       4     5     6       7     8     9

Input: A = [ 1 2 3   4 5 6    7 8 9] Output: A = 1    2     3    4     5     6    7     8     9 Complex numbers also have multiple ways of entering them into MATLAB. The following code demonstrates two approaches.

Input: A = [1 2; 3 4] + i*[5 6; 7 8] Output: A = 1.0000 + 5.0000i  2.0000 + 6.0000i 3.0000 + 7.0000i  4.0000 + 8.0000i

Input: A = [1+5i 2+6i; 3+7i 4+8i] Output: A = 1.0000 + 5.0000i  2.0000 + 6.0000i 3.0000 + 7.0000i  4.0000 + 8.0000i

The variables i or j are considered imaginary numbers but can be overwritten as regular variables. If this does happen then one can create a new name for the imaginary number by defining it in code. (jj = sqrt(-1) ).

Rectangular arrays consisting of numbers can be viewed from a file using MATLAB’s code:

load filename.ext.

The matrix may then be called up on MATLAB using its filename.

A special rule to note when involving exponential form is to avoid spaces else they will be viewed as two different objects (1.23e-10).

There are several already programmed functions to create matrices. One of which is rand, which creates a randomly numbered matrix. The function rand(n) will create a square matrix of n2 entries. However, if a rectangular matrix is desired, rand(m,n) produces a matrix m x n.

Input: rand(3) Output: ans = 0.9501   0.4860    0.4565    0.2311    0.8913    0.0185    0.6068    0.7621    0.8214

Input: rand(3,2) Output: ans = 0.4447   0.9218    0.6154    0.7382    0.7919    0.1763

Another built-in function that MATLAB contains is the magic command. magic(n) yields a matrix where no matter the size of the square matrix, all rows, columns, and diagonals will have the same sum.

Input: magic(5) Output: ans = 17   24     1     8    15    23     5     7    14    16     4     6    13    20    22    10    12    19    21     3    11    18    25     2     9

The final example of programmed functions in MATLAB is the Hilbert matrix. Typing hilb will yield a matrix with each element following the equation:.

Input: hilb(3) Output: ans = 1.0000   0.5000    0.3333    0.5000    0.3333    0.2500    0.3333    0.2500    0.2000

To call up a single entry from a matrix, one must use the format matrixname(i,j). The following is an example of this using the last version of matrix A.

Input: A(2,2) Output: ans = 4.0000 + 8.0000i

Matrix operations, array operations.
There are several operations in MATLAB that can be performed on matrices and scalars, including addition, subtraction, multiplication, power, conjugate transpose, and left and right division. The left and right division for matrices is shown below. Two rules to follow are:

If x = A\b then A*x=b (Using Gaussian elimination if A is square, else                                                    Householder orthogonalization.)

If x = b/A then x*A=b (Defined by b/A=(A'\b')'.)

where A is an invertible square matrix and b is a compatible column.

Input: A Output: A = 0    0     8     8     0     4     0    16     0

Input: b= [ 2 3 7; 5 4 3; 5 9 0] Output: b = 2    3     7     5     4     3     5     9     0

Input: x=A\b Output: x = 0.5000   0.3125   -0.0625     0.3125    0.5625         0     0.2500    0.3750    0.8750

Input: A*x Output: ans = 2    3     7     5     4     3     5     9     0

Input: x=b/A Output: x = 0.7500   0.2500    0.1875    0.0625    0.6250    0.2500   -0.3125    0.6250    0.5625

Input: x*A Output: ans = 2    3     7     5     4     3     5     9     0

Input: (A'\b')' Output: ans = 0.7500   0.2500    0.1875     0.0625    0.6250    0.2500    -0.3125    0.6250    0.5625

Array operations.

While the matrix operations mentioned above operate matrix-wise, they can be also used to operate entry-wise. If a period is added before the operation, then MATLAB will recognize this command as an entry by entry operation. Examples are shown below.

Input: [1,2,3,4].*[1,2,3,4] Output: ans = 1    4     9    16

Input: [1,2,3,4].^2 Output: ans = 1    4     9    16

Statements, expression, and variables; saving a session
When typing in commands or variables, MATLAB is case sensitive. Therefore, if variable A is assigned to a matrix then calling up a in the future will not bring up matrix A.

When entering a statement into MATLAB, it is stored into the memory either to the variable name assigned by the user or to ans which can be called back for future use. Statements usually end with the enter key, however if there is a comma or semicolon more than one statements may be made in the same line. Additionally instead of terminating the statement at the end of a line, a semicolon will continue until ended with the enter key without one.

To list all variables in the workspace, the command who or whos can be used. The variables can be reassigned or can be cleared from the memory. The command clear variable is used to clear the variable. Below are examples of the commands who and clear. clear alone deletes all user assigned variables. After logging out of a MATLAB session, all variable assignments are lost.

Input: who Output: Your variables are: A   ans  b    p    x

clear ans

If an operation is runaway or seems to never stop computing, pressing CTRL-C will break the computation in MATLAB.

To save the workspace before exiting, the command save will write all variables to a diskfile. After restarting MATLAB, the last workspace saved can be called back to its previous state with the command load. Input: save Output: Saving to: matlab.mat

Matrix building functions
A few matrix building functions include
 * eye : identity matrix
 * zeros: matrix of zeros
 * ones : matrix of ones
 * diag : create or extract diagonals
 * 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
 * zeros(m,n) produces an m-by-n matrix of zeros and zeros(n) produces an n-by-n one

Examples:

zeros(3)

ans = 0    0     0    0     0     0    0     0     0

zeros(2,3)

ans = 0    0     0    0     0     0

A = ans; zeros(size(A))

ans = 0    0     0    0     0     0

Diag(x) produces a matrix with the vector x down the diagonal; If A is a square matrix, then diag(A) is a vector consisting of the diagonal of A

Examples:

x = [1 2 3 4]; diag(x)

ans = 1    0     0     0    0     2     0     0    0     0     3     0    0     0     0     4

A = [1 2; 3 4]

A = 1    2    3     4

diag(A) ans = 1   4

diag(diag(A)) ans = 1    0    0     4

Matrices can be built from blocks; if A is a 3-by-3 matrix, then

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

B = 1    1     1     0     0    1     1     1     0     0    1     1     1     0     0    0     0     0     1     0    0     0     0     0     1

For Loop
A For loop executes a block of code a specified number of times;

n=4; x=[]; for i=1:n, x=[x,i^2],end

x = 1

x = 1    4

x = 1    4     9

x = 1    4     9    16

m=3; for i=1:m, for j=1:n, H(i,j)=1/(i+j-1); end, end, H

H = 1.0000   0.5000    0.3333    0.2500    0.5000    0.3333    0.2500    0.2000    0.3333    0.2500    0.2000    0.1667

The semicolon in the above code suppresses printing of H, while the last H displays the final result, a hilbert matrix

While Loops
While loops allow their statements to be repeatedly executed as long as the relation remains true

a=5; n=0; while 2^n < a, n=n+1; end, n

n = 3

If Statement
The "if" statement executes the procedures inside the loop as long as the relation is true.

if n<0, parity = 0; elseif rem(n,2) == 0, parity = 2; else, parity = 1; end

parity

parity = 1

Relations
Here are the relation operators in MATLAB:
 * < less than
 * > greater than
 * <= less than or equal
 * >= greater than or equal
 * == equal
 * ~= not equal
 * note: "=" is used for assignment while "==" is used for relation

Relations can be connected or quantified by logical operators:
 * "&" and
 * "|" or
 * "~" not

When applied to scalars, a relation is actually the scalar 1 for true or 0 for false.

3<5   ans =   1

3>5   ans =   0

3==5   ans =   0

3==3   ans =   1

a = rand(5) a = 0.9355   0.3529    0.1987    0.7468    0.8462   0.9169    0.8132    0.6038    0.4451    0.5252   0.4103    0.0099    0.2722    0.9318    0.2026   0.8936    0.1389    0.1988    0.4660    0.6721   0.0579    0.2028    0.0153    0.4186    0.8381

b = triu(a)

b = 0.9355   0.3529    0.1987    0.7468    0.8462        0    0.8132    0.6038    0.4451    0.5252        0         0    0.2722    0.9318    0.2026        0         0         0    0.4660    0.6721        0         0         0         0    0.8381

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

A relation between matrices is interpreted by "while" and "if" to be true if each entry of the relation matrix is nonzero. For example if A and B are equal matrices, then if A==B, "statement"; end.

Scalar Functions
Certain functions operate on scalars, but operate element-wise when applied to a matrix. These functions are shown in the table below:

 * see help files for examples of these

Vector Functions
Some MATLAB functions operate on vectors, and for an m-by-n, where m is greater than or equal to 2, these functions operate on a column basis. Row-by-row fashion can be obtained by using the transpose of the function, hence mean(A')'. Here are a few of the vector functions available:

Example:

A = [1,2;3,4]

A = 1    2       3     4

max(max(A))

ans = 4

max(A)

ans = 3    4

Matrix Functions
MATLAB's real computing power comes from its matrix functions. Here are a few:
 * eig : eigenvalues and eigenvectors
 * chol : cholesky factorization
 * svd : singular 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

Example:

A = rand(3,3)

A = 0.9649   0.9572    0.1419    0.1576    0.4854    0.4218    0.9706    0.8003    0.9157

eig(A)

ans = 1.8146             0.2757 + 0.3061i 0.2757 - 0.3061i

[U,D] = eig(A)

U = 0.4913            0.6696             0.6696              0.3158            -0.4476 + 0.2831i  -0.4476 - 0.2831i 0.8117           -0.2332 - 0.4655i  -0.2332 + 0.4655i

D = 1.8146                 0                  0                   0             0.2757 + 0.3061i        0 0                 0             0.2757 - 0.3061i

Command Line Editing and Recall
Editing the command line can be done using the left/right arrows, as well as the backspace button for deletion. To scroll through previously entered commands using the up/down arrows. This is much more efficient for small routines as switching between M-file and command window can be tedious.

Example:

a = rand(8)

a = Columns 1 through 6 0.5853   0.0759    0.0119    0.2630    0.1524    0.0046      0.5497    0.0540    0.3371    0.6541    0.8258    0.7749      0.9172    0.5308    0.1622    0.6892    0.5383    0.8173      0.2858    0.7792    0.7943    0.7482    0.9961    0.8687      0.7572    0.9340    0.3112    0.4505    0.0782    0.0844      0.7537    0.1299    0.5285    0.0838    0.4427    0.3998      0.3804    0.5688    0.1656    0.2290    0.1067    0.2599      0.5678    0.4694    0.6020    0.9133    0.9619    0.8001    Columns 7 through 8 0.4314   0.5499      0.9106    0.1450      0.1818    0.8530      0.2638    0.6221      0.1455    0.3510      0.1361    0.5132      0.8693    0.4018      0.5797    0.0760

a = inv(a)

a = Columns 1 through 5 -0.7806   4.7641   -0.5126    0.4986    3.2273   -2.5268   13.4861   -2.1132    4.5763    8.5986    2.8760  -22.3594    2.5534   -6.6821  -12.7484    3.8710  -20.5717    3.3312   -6.3999  -11.6863   -3.2488   31.3116   -5.4853   10.5614   18.0258   -1.0536   -7.8019    2.5877   -3.0862   -5.2544    0.3442   -0.5124   -0.2746   -0.3617   -0.7195    1.7237   -4.8181    0.9024   -0.5737   -3.1429  Columns 6 through 8 0.0232  -2.3877   -4.2041   -2.4798   -5.7673  -13.6525    4.5481   10.2127   22.0422    2.0557    8.5971   20.8620   -5.0720  -15.0243  -30.6600    1.6697    4.5284    7.7693    0.0589    1.2575    0.8056    0.5811    2.1432    3.7028

Submatrices and Colon Notation
Colon notation is used to generate vectors and reference submatrices. It accomplishes similar functions to the for statement. For an example in generating vectors the input

0:0.2:1

creates the output line vector

[0, 0.2, 0.4, 0.6, 0.8, 1].

With colon notation the beginning value, increment, and ending value can all be specified. This notation is handy when graphing functions and needing specific increments on the x-axis.

For an example in referencing submatrices:

A(1:3,4)

is the column vector of the first three entries of the fourth column.

A(:,4)

is the entire fourth column.

A(:,[1 3]

is columns 2 and 4 of A.

A(:,[2 4 5] ) = B(:,1:3)

replaces columns 2, 4, and 5 of A with the first three columns of B.

M-files
M-files are files stored as either “script files” or “function files” with file type of “.m”. A script file consists of normal MATLAB statements. For example if there is a file file.m then the command file would input all the statements in the m-file. However, be careful because calling the m-file will overwrite any information that conflicts.

Function files take input from MATLAB perform an operation and then provide an output back to MATLAB. For example the function randint.m,

Function a = randint(m,n) %RANDINT Randomly generates intergral matrix. %randint(m,n) returns an m-by-n matrix with entries %between 0 and 9. %Rnad(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(m,n) +a;

If this function is called by z = randint(4,5), then 4 and 5 are passed to the variable m and n and the out of the m-file is assigned to the variable z. Some MATLAB functions are built in to the program but you can create your own as well.

Text Strings, Error Messages, Input
Text strings are entered into MATLAB by single quotes, for example ‘MATLAB’. The display command,

disp(‘MATLAB’)

displays the text inside the parentheses. There is also an error function available for notifying a user that their input into a m-file causes an error,

error(‘Sorry, error’)

and when placed in an m-file the error command aborts the m-file. Also, a user can be prompted to input data into an m-file with the command,

input(‘Enter a value: ’).

Managing M-Files
When using Matlab, it is sometimes necessary to move to another workspace (text editor, graphic viewer, etc.) while MATLAB is still active. The !- feature can be used to prevent exiting MATLAB while performing operations in a separate program. For instance, one can edit the file EML4500.m in a local text editor by typing

When the user is finished editing the file, they will be returned to an active MATLAB window.

M-files should be stored in a dedicated directory so that they can be easily accessed by MATLAB. The default active directory of MATLAB is C:\Program Files\MATLAB\R2006\work, but the user may choose to create another active work directory. To change the active directory or to create an additional MATLAB search path, navigate to File -> set Path... and perform any necessary changes. Note that MATLAB does include subdirectories in its search path, which allows the user to save M-files in subfolders and still be able to execute them in a MATLAB session.

The table below lists commands that will be useful when working with M-files:

Comparing efficiency of algorithms: Flops, tic and toc
When creating computer-intensive MATLAB code, it is often wise to create an algorithm that is efficient as possible. Two way to asses the efficiency of an algorithm are the amount of floating point operations (flops) performed and the elapsed time.

The MATLAB function records the total number of flops performed. The command  resets the flops to zero and is normally entered prior to running a an algorithm. Entering the  command after executing the algorithm gives the flops count for the algorithm. For example, the number of flops required to solve the equation c = a + b can be obtained with:

NOTE: With MATLAB ver. 7 and newer, the  command can no longer be used. MATLAB will display the following error:

function f = flops(x) %FLOPS Obsolete floating point operation count. %  Earlier versions of MATLAB counted the number of floating point %  operations. With the incorporation of LAPACK in MATLAB 6, this %  is no longer practical. %  Copyright 1984-2004 The MathWorks, Inc.     %   $Revision: 5.12.4.1 $  $Date: 2004/01/24 09:21:21 if (nargin < 1) || (x ~= 0) warning('MATLAB:flops:UnavailableFunction', ...       'Flop counts are no longer available.') end if nargout > 0 f = 0; end

While the flops command may not work for all users, the elapsed time can still be obtained. The time required to solve an algorithm can be found by using the stopwatch timers  and. For example, to find the total time needed to solve the equation, use the following command;

It should be noted, however, that the elapsed time may not be the best measure of algorithm efficiency because the rate of execution depends on how busy the processor is.

Output format
Even though all computations in MATLAB are performed in double precision, the format of the output display can be altered by the following commands:

Once introduced, the chosen format will remain in effect until changed.

The command  will suppress blank line allowing more information to be seen on the screen.

The command  returns MATLAB to the non-compact format.

Hardcopy
The Hardcopy function is used to save your work to a file on your computer. To use this feature, the user enters in “diary filename” where filename is the desired name of the file. If no name is given, the file will automatically be called diary. The file can be edited as desired and printed using the !-feature.

Graphics
To graph a planar plot in MATLAB, one can use the plot function. Once the x and y vectors and defined by the user, a graphic plot can be obtained by entering “plot(x,y).” Sample code is provided as an example.

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

This will open up a window with the graph, called figure 1. To open a new blank figure without editing the old one, the user can type in “figure(2).” This new figure is now the active graph, and any code entered will only effect this window. The user can enter in “figure(1)” to make the old figure active when so desired.

Graphing over an interval of numbers can be done by placing a colon on either side of the values of x. For example,

x=-1.5:.01:1.5

will set x to the value of .01 only over the interval from -1.5 to 1.5.

Graphs can also be produced by using the fplot command. Typing in “fplot(‘functionname’)” will graph a function that has been previously saved as an M-file.

To make a parametric plot, simply enter in the values for x,y, and t. Sample code is provided.

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

Once a plot is made, the axis and title can be edited using the “title”, “xlabel”, and “ylabel” commands. “gtext” Will place a text box at a point specified by the user with the mouse. “text” will place a text box at the given coordinates. A samlple title code is given below.

title(‘Best Least Squares Fit’)

The axis can also be edited by using the “axis([xmin,xmax,ymin,ymax])”, “axis(axis)”, “axis auto”, “v=axis”, “axis square”, “axis equal”, “axis off”, and “axis on” commands.

To plot multiple y functions on a single graph, one can designate multiple y values. Sample code is provided.

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

This same feature can be done by creating a Y matrix and then plotting that matrix with respect to x.

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

Multiple plots on the same graph can also be achieved with the hold command. Entering “hold” will cause MATLAB to plot all subsequent graphs on the current active window.

It is also possible to change the color and type of the data line as well as the color and type of the data points. Sample code is provided.

x=0:.01:2*pi y1=sin(x) y2=sin(2*x) y3=sin(4*x) plot(x,y1,'--',x,y2,':',x,y3,'+') plot(x,y,'r--')

That code will cause y1 to be plotted with a dashed line, y2 to be plotted with a dotted line, and y3 to have a plus sign an each data point. The r before the “—“ in the last line of code will cause the dashed line to be red.

The command subplot will place several smaller plots on the same figure.

To print a hardcopy of a graphic, one can use the print command. If the command is followed by the filename, MATLAB will save the graphic file to the computer. The graphic can be appended if edited by entering “print –append filename”.

MATLAB is also capable of producing 3-D plots. Sample code for producing a parametric 3-D plot is given below.

t-.01:.01:20*pi x=cos(t) y=sin(t) z=t z=t.^3 plot3(x,y,z)

The title, data points, and axis can be label and edited just as a 2-D plot could be.

MATLAB can also render various graphical effects, such as a mesh grid or surf plot. The “mesh” command will produce a mesh over the surface of the graph, while surf will produce a shaded surface over the graph. Sample code to produce a mesh graph is shown below.

xx=-2:.2:2 yy=xx [x,y]=mesh grid(xx,yy) z=exp(-x.^2 - y.^2) mesh(z)

Entering in “surf(z)” would turn this graph into a surf plot.

The shading schemes of the surface can be edit using the “faceted”, “interpolated”, and “flat” commands. The color schemes available in MATLAB are “hsv”, “hot”, “cool”, “jet”, “pink”, “copper”, “flag”, “gray”, and “bone”.

Parametric surface plots can be made using the sphere and cylinder commands. The following sample code is an example of how to graph a torus.

function [x,y,z] = torus(r,n,a) if nargin < 3, a=1; end if nargin < 3, a=1 if nargin < 2, n = 30 if nargin < 1, r = 0.5 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

Sparse Matrix Computations
MATLAB can reduce a matrix to a “sparse” matrix by only saving the elements in the matrix that are non-zero. Therefore, it can perform calculations faster by storing a matrix as a sparse matrix rather than a full “dense” matrix. The commands “full” and “sparse” are used to change a matrix to either type. The following code will create a sparse matrix.

F=floor(10*rand(6)) F=triu(tril(F,1),-1) S=sparse(F)

To return this matrix to full, enter the command “F=full(S)”. It is also possible to see if a matrix is full or sparse using the “issparse(F)” command.

To create a sparse banded matrix using the spdiags command, use the following code.

m=6 n=6 e=ones(n,1) d=-2*e T=spdiags([e,d,e],[-1,0,1],m,n)

Another way to enter in a sparse matrix is to only enter in the non-zero elements. Example code for this is shown below.

i=[1 2 3 4 4 4] j = [1 2 3 1 2 3] s = [5 6 7 8 9 10] S=sparse(i,j,s,4,3), full(S)

Operations can by applied to any matrix regardless if it is sparse or full.


text:
User:Eml4500.f08.qwiki.bishop/HW1

 Comment: This page contains the same content as the previous one, except that it is located in the user namespace instead of in the main namespace and the layout of the page is reorganized. Here is a comparison between these two versions. Chris Bishop Eml4500.f08.qwiki.bishop 20:10, 4 November 2008 (UTC)

=Basic Information=
 * Dr. Vu-Quoc Website
 * Course Website
 * Syllabus

Team Information

 * Class Teams
 * No less than 5 people, but no more than 6 people...5.5 people?
 * Team names 6 characters long
 * Team info
 * Member names
 * UFID
 * Phone number
 * E-mail

Matlab Primer
=Matlab Primer= Link to MATLAB Primer: http://apollo.mae.ufl.edu/~vql/courses/feem/matlab_primer_3rd.pdf

Accessing MATLAB
Almost all versions of MATLAB include an icon on the desktop in which you can open MATLAB. Also there is the option of going through the start menu. While in MATLAB, to exit the command is quit or exit.

Entering Matrices
In MATLAB, all entries are treated as a matrix. They can be only a 1x1 matrix, up to nxn matrices, where n is an integer. Scalars are considered 1x1 matrices and vectors are either 1 row or 1 column matrices.

There are multiple ways to write matrices in MATLAB. The following are two different codes for producing matrix A.

Input: A = [1 2 3; 4 5 6; 7 8 9] Output: A = 1    2     3       4     5     6       7     8     9

Input: A = [ 1 2 3   4 5 6    7 8 9] Output: A = 1    2     3    4     5     6    7     8     9 Complex numbers also have multiple ways of entering them into MATLAB. The following code demonstrates two approaches.

Input: A = [1 2; 3 4] + i*[5 6; 7 8] Output: A = 1.0000 + 5.0000i  2.0000 + 6.0000i 3.0000 + 7.0000i  4.0000 + 8.0000i

Input: A = [1+5i 2+6i; 3+7i 4+8i] Output: A = 1.0000 + 5.0000i  2.0000 + 6.0000i 3.0000 + 7.0000i  4.0000 + 8.0000i

The variables i or j are considered imaginary numbers but can be overwritten as regular variables. If this does happen then one can create a new name for the imaginary number by defining it in code. (jj = sqrt(-1) ).

Rectangular arrays consisting of numbers can be viewed from a file using MATLAB’s code:

load filename.ext.

The matrix may then be called up on MATLAB using its filename.

A special rule to note when involving exponential form is to avoid spaces else they will be viewed as two different objects (1.23e-10).

There are several already programmed functions to create matrices. One of which is rand, which creates a randomly numbered matrix. The function rand(n) will create a square matrix of n2 entries. However, if a rectangular matrix is desired, rand(m,n) produces a matrix m x n.

Input: rand(3) Output: ans = 0.9501   0.4860    0.4565    0.2311    0.8913    0.0185    0.6068    0.7621    0.8214

Input: rand(3,2) Output: ans = 0.4447   0.9218    0.6154    0.7382    0.7919    0.1763

Another built-in function that MATLAB contains is the magic command. magic(n) yields a matrix where no matter the size of the square matrix, all rows, columns, and diagonals will have the same sum.

Input: magic(5) Output: ans = 17   24     1     8    15    23     5     7    14    16     4     6    13    20    22    10    12    19    21     3    11    18    25     2     9

The final example of programmed functions in MATLAB is the Hilbert matrix. Typing hilb will yield a matrix with each element following the equation:.

Input: hilb(3) Output: ans = 1.0000   0.5000    0.3333    0.5000    0.3333    0.2500    0.3333    0.2500    0.2000

To call up a single entry from a matrix, one must use the format matrixname(i,j). The following is an example of this using the last version of matrix A.

Input: A(2,2) Output: ans = 4.0000 + 8.0000i

Matrix operations, array operations.
There are several operations in MATLAB that can be performed on matrices and scalars, including addition, subtraction, multiplication, power, conjugate transpose, and left and right division. The left and right division for matrices is shown below. Two rules to follow are:

If x = A\b then A*x=b (Using Gaussian elimination if A is square, else                                                    Householder orthogonalization.)

If x = b/A then x*A=b (Defined by b/A=(A'\b')'.)

where A is an invertible square matrix and b is a compatible column.

Input: A Output: A = 0    0     8     8     0     4     0    16     0

Input: b= [ 2 3 7; 5 4 3; 5 9 0] Output: b = 2    3     7     5     4     3     5     9     0

Input: x=A\b Output: x = 0.5000   0.3125   -0.0625     0.3125    0.5625         0     0.2500    0.3750    0.8750

Input: A*x Output: ans = 2    3     7     5     4     3     5     9     0

Input: x=b/A Output: x = 0.7500   0.2500    0.1875    0.0625    0.6250    0.2500   -0.3125    0.6250    0.5625

Input: x*A Output: ans = 2    3     7     5     4     3     5     9     0

Input: (A'\b')' Output: ans = 0.7500   0.2500    0.1875     0.0625    0.6250    0.2500    -0.3125    0.6250    0.5625

Array operations.

While the matrix operations mentioned above operate matrix-wise, they can be also used to operate entry-wise. If a period is added before the operation, then MATLAB will recognize this command as an entry by entry operation. Examples are shown below.

Input: [1,2,3,4].*[1,2,3,4] Output: ans = 1    4     9    16

Input: [1,2,3,4].^2 Output: ans = 1    4     9    16

Statements, expression, and variables; saving a session
When typing in commands or variables, MATLAB is case sensitive. Therefore, if variable A is assigned to a matrix then calling up a in the future will not bring up matrix A.

When entering a statement into MATLAB, it is stored into the memory either to the variable name assigned by the user or to ans which can be called back for future use. Statements usually end with the enter key, however if there is a comma or semicolon more than one statements may be made in the same line. Additionally instead of terminating the statement at the end of a line, a semicolon will continue until ended with the enter key without one.

To list all variables in the workspace, the command who or whos can be used. The variables can be reassigned or can be cleared from the memory. The command clear variable is used to clear the variable. Below are examples of the commands who and clear. clear alone deletes all user assigned variables. After logging out of a MATLAB session, all variable assignments are lost.

Input: who Output: Your variables are: A   ans  b    p    x

clear ans

If an operation is runaway or seems to never stop computing, pressing CTRL-C will break the computation in MATLAB.

To save the workspace before exiting, the command save will write all variables to a diskfile. After restarting MATLAB, the last workspace saved can be called back to its previous state with the command load. Input: save Output: Saving to: matlab.mat

Matrix building functions
A few matrix building functions include
 * eye : identity matrix
 * zeros: matrix of zeros
 * ones : matrix of ones
 * diag : create or extract diagonals
 * 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
 * zeros(m,n) produces an m-by-n matrix of zeros and zeros(n) produces an n-by-n one

Examples:

zeros(3)

ans = 0    0     0    0     0     0    0     0     0

zeros(2,3)

ans = 0    0     0    0     0     0

A = ans; zeros(size(A))

ans = 0    0     0    0     0     0

Diag(x) produces a matrix with the vector x down the diagonal; If A is a square matrix, then diag(A) is a vector consisting of the diagonal of A

Examples:

x = [1 2 3 4]; diag(x)

ans = 1    0     0     0    0     2     0     0    0     0     3     0    0     0     0     4

A = [1 2; 3 4]

A = 1    2    3     4

diag(A) ans = 1   4

diag(diag(A)) ans = 1    0    0     4

Matrices can be built from blocks; if A is a 3-by-3 matrix, then

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

B = 1    1     1     0     0    1     1     1     0     0    1     1     1     0     0    0     0     0     1     0    0     0     0     0     1

For Loop
A For loop executes a block of code a specified number of times;

n=4; x=[]; for i=1:n, x=[x,i^2],end

x = 1

x = 1    4

x = 1    4     9

x = 1    4     9    16

m=3; for i=1:m, for j=1:n, H(i,j)=1/(i+j-1); end, end, H

H = 1.0000   0.5000    0.3333    0.2500    0.5000    0.3333    0.2500    0.2000    0.3333    0.2500    0.2000    0.1667

The semicolon in the above code suppresses printing of H, while the last H displays the final result, a hilbert matrix

While Loops
While loops allow their statements to be repeatedly executed as long as the relation remains true

a=5; n=0; while 2^n < a, n=n+1; end, n

n = 3

If Statement
The "if" statement executes the procedures inside the loop as long as the relation is true.

if n<0, parity = 0; elseif rem(n,2) == 0, parity = 2; else, parity = 1; end

parity

parity = 1

Relations
Here are the relation operators in MATLAB:
 * < less than
 * > greater than
 * <= less than or equal
 * >= greater than or equal
 * == equal
 * ~= not equal
 * note: "=" is used for assignment while "==" is used for relation

Relations can be connected or quantified by logical operators:
 * "&" and
 * "|" or
 * "~" not

When applied to scalars, a relation is actually the scalar 1 for true or 0 for false.

3<5   ans =   1

3>5   ans =   0

3==5   ans =   0

3==3   ans =   1

a = rand(5) a = 0.9355   0.3529    0.1987    0.7468    0.8462   0.9169    0.8132    0.6038    0.4451    0.5252   0.4103    0.0099    0.2722    0.9318    0.2026   0.8936    0.1389    0.1988    0.4660    0.6721   0.0579    0.2028    0.0153    0.4186    0.8381

b = triu(a)

b = 0.9355   0.3529    0.1987    0.7468    0.8462        0    0.8132    0.6038    0.4451    0.5252        0         0    0.2722    0.9318    0.2026        0         0         0    0.4660    0.6721        0         0         0         0    0.8381

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

A relation between matrices is interpreted by "while" and "if" to be true if each entry of the relation matrix is nonzero. For example if A and B are equal matrices, then if A==B, "statement"; end.

Scalar Functions
Certain functions operate on scalars, but operate element-wise when applied to a matrix. These functions are shown in the table below:

 * see help files for examples of these

Vector Functions
Some MATLAB functions operate on vectors, and for an m-by-n, where m is greater than or equal to 2, these functions operate on a column basis. Row-by-row fashion can be obtained by using the transpose of the function, hence mean(A')'. Here are a few of the vector functions available:

Example:

A = [1,2;3,4]

A = 1    2       3     4

max(max(A))

ans = 4

max(A)

ans = 3    4

Matrix Functions
MATLAB's real computing power comes from its matrix functions. Here are a few:
 * eig : eigenvalues and eigenvectors
 * chol : cholesky factorization
 * svd : singular 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

Example:

A = rand(3,3)

A = 0.9649   0.9572    0.1419    0.1576    0.4854    0.4218    0.9706    0.8003    0.9157

eig(A)

ans = 1.8146             0.2757 + 0.3061i 0.2757 - 0.3061i

[U,D] = eig(A)

U = 0.4913            0.6696             0.6696              0.3158            -0.4476 + 0.2831i  -0.4476 - 0.2831i 0.8117           -0.2332 - 0.4655i  -0.2332 + 0.4655i

D = 1.8146                 0                  0                   0             0.2757 + 0.3061i        0 0                 0             0.2757 - 0.3061i

Command Line Editing and Recall
Editing the command line can be done using the left/right arrows, as well as the backspace button for deletion. To scroll through previously entered commands using the up/down arrows. This is much more efficient for small routines as switching between M-file and command window can be tedious.

Example:

a = rand(8)

a = Columns 1 through 6 0.5853   0.0759    0.0119    0.2630    0.1524    0.0046      0.5497    0.0540    0.3371    0.6541    0.8258    0.7749      0.9172    0.5308    0.1622    0.6892    0.5383    0.8173      0.2858    0.7792    0.7943    0.7482    0.9961    0.8687      0.7572    0.9340    0.3112    0.4505    0.0782    0.0844      0.7537    0.1299    0.5285    0.0838    0.4427    0.3998      0.3804    0.5688    0.1656    0.2290    0.1067    0.2599      0.5678    0.4694    0.6020    0.9133    0.9619    0.8001    Columns 7 through 8 0.4314   0.5499      0.9106    0.1450      0.1818    0.8530      0.2638    0.6221      0.1455    0.3510      0.1361    0.5132      0.8693    0.4018      0.5797    0.0760

a = inv(a)

a = Columns 1 through 5 -0.7806   4.7641   -0.5126    0.4986    3.2273   -2.5268   13.4861   -2.1132    4.5763    8.5986    2.8760  -22.3594    2.5534   -6.6821  -12.7484    3.8710  -20.5717    3.3312   -6.3999  -11.6863   -3.2488   31.3116   -5.4853   10.5614   18.0258   -1.0536   -7.8019    2.5877   -3.0862   -5.2544    0.3442   -0.5124   -0.2746   -0.3617   -0.7195    1.7237   -4.8181    0.9024   -0.5737   -3.1429  Columns 6 through 8 0.0232  -2.3877   -4.2041   -2.4798   -5.7673  -13.6525    4.5481   10.2127   22.0422    2.0557    8.5971   20.8620   -5.0720  -15.0243  -30.6600    1.6697    4.5284    7.7693    0.0589    1.2575    0.8056    0.5811    2.1432    3.7028

Submatrices and Colon Notation
Colon notation is used to generate vectors and reference submatrices. It accomplishes similar functions to the for statement. For an example in generating vectors the input

0:0.2:1

creates the output line vector

[0, 0.2, 0.4, 0.6, 0.8, 1].

With colon notation the beginning value, increment, and ending value can all be specified. This notation is handy when graphing functions and needing specific increments on the x-axis.

For an example in referencing submatrices:

A(1:3,4)

is the column vector of the first three entries of the fourth column.

A(:,4)

is the entire fourth column.

A(:,[1 3]

is columns 2 and 4 of A.

A(:,[2 4 5] ) = B(:,1:3)

replaces columns 2, 4, and 5 of A with the first three columns of B.

M-files
M-files are files stored as either “script files” or “function files” with file type of “.m”. A script file consists of normal MATLAB statements. For example if there is a file file.m then the command file would input all the statements in the m-file. However, be careful because calling the m-file will overwrite any information that conflicts.

Function files take input from MATLAB perform an operation and then provide an output back to MATLAB. For example the function randint.m,

Function a = randint(m,n) %RANDINT Randomly generates intergral matrix. %randint(m,n) returns an m-by-n matrix with entries %between 0 and 9. %Rnad(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(m,n) +a;

If this function is called by z = randint(4,5), then 4 and 5 are passed to the variable m and n and the out of the m-file is assigned to the variable z. Some MATLAB functions are built in to the program but you can create your own as well.

Text Strings, Error Messages, Input
Text strings are entered into MATLAB by single quotes, for example ‘MATLAB’. The display command,

disp(‘MATLAB’)

displays the text inside the parentheses. There is also an error function available for notifying a user that their input into a m-file causes an error,

error(‘Sorry, error’)

and when placed in an m-file the error command aborts the m-file. Also, a user can be prompted to input data into an m-file with the command,

input(‘Enter a value: ’).

Managing M-Files
When using Matlab, it is sometimes necessary to move to another workspace (text editor, graphic viewer, etc.) while MATLAB is still active. The !- feature can be used to prevent exiting MATLAB while performing operations in a separate program. For instance, one can edit the file EML4500.m in a local text editor by typing

When the user is finished editing the file, they will be returned to an active MATLAB window.

M-files should be stored in a dedicated directory so that they can be easily accessed by MATLAB. The default active directory of MATLAB is C:\Program Files\MATLAB\R2006\work, but the user may choose to create another active work directory. To change the active directory or to create an additional MATLAB search path, navigate to File -> set Path... and perform any necessary changes. Note that MATLAB does include subdirectories in its search path, which allows the user to save M-files in subfolders and still be able to execute them in a MATLAB session.

The table below lists commands that will be useful when working with M-files:

Comparing efficiency of algorithms: Flops, tic and toc
When creating computer-intensive MATLAB code, it is often wise to create an algorithm that is efficient as possible. Two way to asses the efficiency of an algorithm are the amount of floating point operations (flops) performed and the elapsed time.

The MATLAB function records the total number of flops performed. The command  resets the flops to zero and is normally entered prior to running a an algorithm. Entering the  command after executing the algorithm gives the flops count for the algorithm. For example, the number of flops required to solve the equation c = a + b can be obtained with:

NOTE: With MATLAB ver. 7 and newer, the  command can no longer be used. MATLAB will display the following error:

While the flops command may not work for all users, the elapsed time can still be obtained. The time required to solve an algorithm can be found by using the stopwatch timers  and. For example, to find the total time needed to solve the equation, use the following command;

It should be noted, however, that the elapsed time may not be the best measure of algorithm efficiency because the rate of execution depends on how busy the processor is.

Output format
Even though all computations in MATLAB are performed in double precision, the format of the output display can be altered by the following commands:

Once introduced, the chosen format will remain in effect until changed.

The command  will suppress blank line allowing more information to be seen on the screen.

The command  returns MATLAB to the non-compact format.

Hardcopy
The Hardcopy function is used to save your work to a file on your computer. To use this feature, the user enters in “diary filename” where filename is the desired name of the file. If no name is given, the file will automatically be called diary. The file can be edited as desired and printed using the !-feature.

Graphics
To graph a planar plot in MATLAB, one can use the plot function. Once the x and y vectors and defined by the user, a graphic plot can be obtained by entering “plot(x,y).” Sample code is provided as an example.

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

This will open up a window with the graph, called figure 1. To open a new blank figure without editing the old one, the user can type in “figure(2).” This new figure is now the active graph, and any code entered will only effect this window. The user can enter in “figure(1)” to make the old figure active when so desired.

Graphing over an interval of numbers can be done by placing a colon on either side of the values of x. For example,

x=-1.5:.01:1.5

will set x to the value of .01 only over the interval from -1.5 to 1.5.

Graphs can also be produced by using the fplot command. Typing in “fplot(‘functionname’)” will graph a function that has been previously saved as an M-file.

To make a parametric plot, simply enter in the values for x,y, and t. Sample code is provided.

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

Once a plot is made, the axis and title can be edited using the “title”, “xlabel”, and “ylabel” commands. “gtext” Will place a text box at a point specified by the user with the mouse. “text” will place a text box at the given coordinates. A samlple title code is given below.

title(‘Best Least Squares Fit’)

The axis can also be edited by using the “axis([xmin,xmax,ymin,ymax])”, “axis(axis)”, “axis auto”, “v=axis”, “axis square”, “axis equal”, “axis off”, and “axis on” commands.

To plot multiple y functions on a single graph, one can designate multiple y values. Sample code is provided.

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

This same feature can be done by creating a Y matrix and then plotting that matrix with respect to x.

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

Multiple plots on the same graph can also be achieved with the hold command. Entering “hold” will cause MATLAB to plot all subsequent graphs on the current active window.

It is also possible to change the color and type of the data line as well as the color and type of the data points. Sample code is provided.

x=0:.01:2*pi y1=sin(x) y2=sin(2*x) y3=sin(4*x) plot(x,y1,'--',x,y2,':',x,y3,'+') plot(x,y,'r--')

That code will cause y1 to be plotted with a dashed line, y2 to be plotted with a dotted line, and y3 to have a plus sign an each data point. The r before the “—“ in the last line of code will cause the dashed line to be red.

The command subplot will place several smaller plots on the same figure.

To print a hardcopy of a graphic, one can use the print command. If the command is followed by the filename, MATLAB will save the graphic file to the computer. The graphic can be appended if edited by entering “print –append filename”.

MATLAB is also capable of producing 3-D plots. Sample code for producing a parametric 3-D plot is given below.

t-.01:.01:20*pi x=cos(t) y=sin(t) z=t z=t.^3 plot3(x,y,z)

The title, data points, and axis can be label and edited just as a 2-D plot could be.

MATLAB can also render various graphical effects, such as a mesh grid or surf plot. The “mesh” command will produce a mesh over the surface of the graph, while surf will produce a shaded surface over the graph. Sample code to produce a mesh graph is shown below.

xx=-2:.2:2 yy=xx [x,y]=mesh grid(xx,yy) z=exp(-x.^2 - y.^2) mesh(z)

Entering in “surf(z)” would turn this graph into a surf plot.

The shading schemes of the surface can be edit using the “faceted”, “interpolated”, and “flat” commands. The color schemes available in MATLAB are “hsv”, “hot”, “cool”, “jet”, “pink”, “copper”, “flag”, “gray”, and “bone”.

Parametric surface plots can be made using the sphere and cylinder commands. The following sample code is an example of how to graph a torus.

function [x,y,z] = torus(r,n,a) if nargin < 3, a=1; end if nargin < 3, a=1 if nargin < 2, n = 30 if nargin < 1, r = 0.5 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

Sparse Matrix Computations
MATLAB can reduce a matrix to a “sparse” matrix by only saving the elements in the matrix that are non-zero. Therefore, it can perform calculations faster by storing a matrix as a sparse matrix rather than a full “dense” matrix. The commands “full” and “sparse” are used to change a matrix to either type. The following code will create a sparse matrix.

F=floor(10*rand(6)) F=triu(tril(F,1),-1) S=sparse(F)

To return this matrix to full, enter the command “F=full(S)”. It is also possible to see if a matrix is full or sparse using the “issparse(F)” command.

To create a sparse banded matrix using the spdiags command, use the following code.

m=6 n=6 e=ones(n,1) d=-2*e T=spdiags([e,d,e],[-1,0,1],m,n)

Another way to enter in a sparse matrix is to only enter in the non-zero elements. Example code for this is shown below.

i=[1 2 3 4 4 4] j = [1 2 3 1 2 3] s = [5 6 7 8 9 10] S=sparse(i,j,s,4,3), full(S)

Operations can by applied to any matrix regardless if it is sparse or full.

Wikipedia Overview

 * Create a Wikipedia account
 * How do I create a wikipedia account, and then do a bunch of other stuff that I need to do to set up my junk so I can get credit on homework?...go here!
 * Wikipedia Security
 * The homework lockdown hacker-proof password is "fall08.wiki"
 * Submit archived copy of homework before deadline
 * How do I submit successfully and securely?...check this out and scroll down
 * How do I know what the homework grading criteria are?
 * Great question, find your answer to this question and others about life here.

=Trusses, Matrix Method= Truss with 2 Elastic (deformable) Bars

Global Free Body Diagram
Global FBD

Note: There are 4 unknown reactions and three equations of equilibrium making this truss statically indeterminant

Seperate FBD's of the bar elements

Bar Element 1

Note: The superscript 1 in parenthesis on each force variable denotes that the force is applied to element 1

Bar Element 2

Note: The superscript 2 in parenthesis on each force variable denotes that the force is applied to element 2

Note: Points 1 and 3 are fixed (constrained) to zero in both the x and y directions

1-D Spring Elements
Next Big Step:Force displacement relation (FD)

Recall:

FD relation of 1-D spring element:

 * 1 end fixed: f = kd (see above figure)

f 2x1= k 2x2 d 2x1
 * 2 ends free:

Case 1: Observer sits on node 1
 * f2 = k(d2-d1)

Case 2: Observer sits on node 2
 * f1+f2=0 Therefore, f1 = k(d1-d2)

=Steps to Solving Simple Trusses=  Read:  Chapter 4 Chapter 1: Big Picture
 * 1.1 Discritization (1.1.1 Plane truss elem)
 * 1.2 Assembly of elem. eqs. Ex. 1.4: Five-bar truss
 * 1.4 Elem Soln and model validity (1.4.1 Plane truss elem)

(1) Global
The displacement dofs are partitioned into: 1)a known part,e.g.(fixed dofs, constraints) 2)an unknown part: solve using FEA

The same for global forces: 1) known part 2) unknown part

(2) Element Picture

 * Element dofs
 * Element forces

(3) Global FD Relations

 * Element stiffness matrices in global coordinates
 * Element force matrices in global coordinates
 * Assembly of element stiffness matrix and element force matrix into global FD relation k nxn d nx1= F nx1

(4) Elimination
The elimination of known dofs to reduce the global FD rel. (stiffness matrix non-singular => invertible)

m = number of unknown displacement dofs

n = number of all displacement dofs
 * m < n

d = k-1 F

(5) Compute
Compute the element forces. Compute the element reactions.

Truss Homework
 Example (HW2):

 * L(1)=4    L(2)=2 (Length)
 * E(1)=3 E(2)=5 (Young's Modulus)
 * A(1)=1 A(2)=2 (Area)

1. Global Picture

 $$F$$ = $$Kd$$

2. Element Picture

3. Global FD at element level

=Contributing Team Members= The following students contributed to this report

Chris Bishop eml4500.f08.qwiki.bishop 17:41, 18 September 2008 (UTC)

Andrea Booher eml4500.f08.qwiki.booher 18:42, 18 September 2008 (UTC)

Eric Gatch eml4500.f08.qwiki.gatch 20:23, 18 September 2008 (UTC)

David Nobles eml4500.f08.qwiki.nobles 23:30, 18 September 2008 (UTC)

Mike Berry Eml4500.f08.qwiki.berry 04:14, 19 September 2008 (UTC)

Lee Harris Eml4500.f08.qwiki.harris 04:26, 19 September 2008 (UTC)

title: User:Eml4500.f08.qwiki.bishop/HW1


text:
User:Eml4500.f08.qwiki.bishop/Lecture 1-3

=Lectures 1-3=
 * Dr. Vu-Quoc Website
 * Course Website
 * Syllabus
 * Class Teams
 * No less than 5 people, but no more than 6 people...5.5 people?
 * Team names 6 characters long
 * Team info
 * Member names
 * UFID
 * Phone number
 * E-mail
 * Create a Wikipedia account
 * How do I create a wikipedia account, and then do a bunch of other stuff that I need to do to set up my junk so I can get credit on homework?...go here!
 * Wikipedia Security
 * The homework lockdown hacker-proof password is "fall08.wiki"
 * Submit archived copy of homework before deadline
 * How do I submit successfully and securely?...check this out and scroll down
 * How do I know what the homework grading criteria are?
 * Great question, find your answer to this question and others about life here.


text:
User:Eml4500.f08.qwiki.bishop/Lecture 4

Trusses, matrix method

Truss with 2 Elastic (deformable) Bars

Note: Points 1 and 3 are fixed (constrained) to zero in both the x and y directions

Global FBD

Note: There are 4 unknown reactions and three equations of equilibrium making this truss statically indeterminant

Seperate FBD's of the bar elements

Bar Element 1

Note: The superscript 1 in parenthesis on each force variable denotes that the force is applied to element 1

Bar Element 2

Note: The superscript 2 in parenthesis on each force variable denotes that the force is applied to element 2

Next Big Step:Force displacement relation (FD)

Recall:

FD relation of 1-D spring element:

 * 1 end fixed: f = kd (see above figure)

f 2x1= k 2x2 d 2x1
 * 2 ends free:

Case 1: Observer sits on node 1
 * f2 = k(d2-d1)

Case 2: Observer sits on node 2
 * f1+f2=0 Therefore, f1 = k(d1-d2)

title: User:Eml4500.f08.qwiki.bishop/Lecture 4


text:
User:Eml4500.f08.qwiki.bishop/Lecture 5

 Read:  Chapter 4 Chapter 1: Big Picture
 * 1.1 Discritization (1.1.1 Plane truss elem)
 * 1.2 Assembly of elem. eqs. Ex. 1.4: Five-bar truss
 * 1.4 Elem Soln and model validity (1.4.1 Plane truss elem)

Steps to solve simple truss system described on 9/3

1. Global:  The displacement dofs are partitioned into: 1)a known part,e.g.(fixed dofs, constraints) 2)an unknown part: solve using FEA

The same for global forces: 1) known part 2) unknown part

2. Element picture:
 * Element dofs
 * Element forces

3. Global FD relation:
 * Element stiffness matrices in global coordinates
 * Element force matrices in global coordinates
 * Assembly of element stiffness matrix and element force matrix into global FD relation k nxn d nx1= F nx1

4. Elimination:  The elimination of known dofs to reduce the global FD rel. (stiffness matrix non-singular => invertible)

m = number of unknown displacement dofs

n = number of all displacement dofs
 * m < n

d = k-1 F

5. Compute Element Forces

6. Compute Reactions

 Example (HW2):

 * L(1)=4    L(2)=2 (Length)
 * E(1)=3 E(2)=5 (Young's Modulus)
 * A(1)=1 A(2)=2 (Area)

1. Global Picture

 $$F$$ = $$Kd$$

title: User:Eml4500.f08.qwiki.bishop/Lecture 5


text:
User:Eml4500.f08.qwiki.bishop/Lecture 6

Continued from Lecture 5
2. Element Picture

3. Global FD at element level

The global force relationship is given by the equation $$F=KD$$, where $$F$$ is the resultant force matrix, $$K$$ is the global stiffness matrix, and $$D$$ is the global displacement matrix.

In matrix format,

$$ k^e = k^e \begin{bmatrix} (l^e)^2 & (l^e m^e) & -(l^e)^2 & -(l^e m^e) \\ (l^e m^e) & (m^e)^2 & -(l^e m^e) & -(m^e)^2 \\ -(l^e)^2 & -(l^e m^e) & (l^e)^2 & (l^e m^e) \\ -(l^e m^e) & -(m^e)^2 & (l^e m^e) & (m^e)^2 \end{bmatrix} $$

Note: The superscript "e" represents the truss element under examination.

$$k^{e}=\frac{E^{e}A^{e}}{L^{e}}$$ This is the axial stiffness of bar element "e"

$$l^{e},m^{e}$$ are director cosines of $$\tilde{x}$$ axis (from local node 1 to local node 2) with respect to the global (x,y) coordinate system.

$$l^{e}=\vec{\tilde{i}}\cdot \vec{i}=cos\theta^{e}$$

$$m^{e}=\vec{\tilde{i}}\cdot \vec{j}=sin\theta^{e}$$

$$\vec{\tilde{i}}\cdot\vec{i}=(cos\theta^{e}\vec{i}+sin\theta^{e}\vec{j})\cdot\vec{i}$$

Distributing by unit vector "i" it is easily seen that the equation reduces to $$l^{e}$$ because a unit vector dotted with itself equals 1, whereas a unit vector dotted with its perpendicular counter part equals 0.

Note: the director cosines are the components of $$\vec{\tilde{i}}$$

$$\vec{\tilde{i}}=cos\theta ^{e}\vec{i}+sin\theta ^{e}\vec{j}$$

HW 2
Solve: $$\vec{\tilde{i}}\cdot\vec{j}$$

$$\vec{\tilde{i}}\cdot\vec{j}=(cos\theta^{e}\vec{i}+sin\theta^{e}\vec{j})\cdot\vec{j}$$

Distributing by unit vector "j" it is easily seen that the equation reduces to $$m^{e}$$ because a unit vector dotted with itself equals 1, whereas a unit vector dotted with its perpendicular counter part equals 0.

Solve the element stiffness matrices using the provided information from the problem at the end of Lecture 5.

Element 1:

$$l^{1}=\frac{\sqrt{3}}{2}$$   $$m^{1}=\frac{1}{2}$$     $$k^{1}=\frac{3}{4}$$

$$\textbf{K}^{1}=\frac{3}{4}\begin{bmatrix} \frac{3}{4} & \frac{\sqrt{3}}{4} & -\frac{3}{4} & -\frac{\sqrt{3}}{4}\\ \frac{\sqrt{3}}{4} & \frac{1}{4} & -\frac{\sqrt{3}}{4} & -\frac{1}{4}\\ -\frac{3}{4} & -\frac{\sqrt{3}}{4} & \frac{3}{4} & \frac{\sqrt{3}}{4}\\ -\frac{\sqrt{3}}{4} & -\frac{1}{4} & \frac{\sqrt{3}}{4} & \frac{1}{4} \end{bmatrix}=\begin{bmatrix} \frac{9}{16} & \frac{3\sqrt{3}}{16} & -\frac{9}{16} & -\frac{3\sqrt{3}}{16}\\ \frac{3\sqrt{3}}{16} & \frac{3}{16} & -\frac{3\sqrt{3}}{16} & -\frac{3}{16}\\ -\frac{9}{16}& -\frac{3\sqrt{3}}{16} & \frac{9}{16} & \frac{3\sqrt{3}}{16}\\ -\frac{3\sqrt{3}}{16} & -\frac{3}{16} & \frac{3\sqrt{3}}{16} & \frac{3}{16} \end{bmatrix}$$

$$l^{2}=\frac{\sqrt{2}}{2}$$   $$m^{2}=-\frac{\sqrt{2}}{2}$$  $$k^{2}=5$$

$$\textbf{K}^{2}=5\begin{bmatrix} \frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & \frac{1}{2}\\ -\frac{1}{2} & \frac{1}{2} & \frac{1}{2} & -\frac{1}{2}\\ -\frac{1}{2} & \frac{1}{2} & \frac{1}{2} & -\frac{1}{2}\\ \frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & \frac{1}{2} \end{bmatrix}=\begin{bmatrix} \frac{5}{2} & -\frac{5}{2} & -\frac{5}{2} & \frac{5}{2}\\ -\frac{5}{2} & \frac{5}{2} & \frac{5}{2} & -\frac{5}{2}\\ -\frac{5}{2} & \frac{5}{2} & \frac{5}{2} & -\frac{5}{2}\\ \frac{5}{2} & -\frac{5}{2} & -\frac{5}{2} & \frac{5}{2} \end{bmatrix}$$

Calculate the axial forces for the statically determinate case:

title: User:Eml4500.f08.qwiki.bishop/Lecture 6


text:
User:Eml4500.f08.qwiki.bishop/Lecture 7

To continue with modeling the 2-bar truss system, element 1 is further examined to find the stiffness matrix k (1). Element 1 is located at an angle $$\theta ^{(1)}={\color{red}30^{\circ}}$$

Therefore inputting this angle into the following equations of the director cosines yields:

$$l^{(1)}=cos\theta ^{(1)}=cos30^{\circ} =\frac{\sqrt{3}}{2}=0.866$$

$$m^{(1)}=sin\theta ^{(1)}=sin30^{\circ} =\frac{1}{2}=0.50$$

Next, to find the stiffness coefficient the below equation is used.

$$k^{(1)}=\frac{E^{(1)} A^{(1)}}{L^{(1)}}=\frac{3*1}{4}=0.75$$

Element Stiffness Matrix:

$$\mathbf{k^{(e)}}=\begin{bmatrix} \mathbf{k}_{11} & \mathbf{k}_{12} & \mathbf{k}_{13} & \mathbf{k}_{14}\\ \mathbf{k}_{21} & \mathbf{k}_{22} & \mathbf{k}_{23} & \mathbf{k}_{24}\\ \mathbf{k}_{31} & \mathbf{k}_{32} & \mathbf{k}_{33} & \mathbf{k}_{34}\\ \mathbf{k}_{41} & \mathbf{k}_{42} & \mathbf{k}_{43} & \mathbf{k}_{44}\\ \end{bmatrix} $$

Knowing the above element stiffness matrix, is the result of:

$$\mathbf{k^{(e)}}=k^{(e)}*\begin{bmatrix} (l^{(e)})^{2} & l^{(e)}m^{(e)} & -(l^{(e)})^{2} & -l^{(e)}m^{(e)}\\ l^{(e)}m^{(e)} & (m^{(e)})^{2} & -l^{(e)}m^{(e)} & -(m^{(e)})^{2}\\ -(l^{(e)})^{2} & -l^{(e)}m^{(e)} & (l^{(e)})^{2} & l^{(e)}m^{(e)}\\ -l^{(e)}m^{(e)} & -(m^{(e)})^{2} & l^{(e)}m^{(e)} & (m^{(e)})^{2} \end{bmatrix}$$

Where (e) is the element number. An example of finding out what each element of the stiffness matrix is shown below.

$$\mathbf{k_{11}}=k^{(1)}*(l^{(1)})^{2}=\frac{3}{4}*(\frac{\sqrt{3}}{2})^{2}=\frac{9}{16}=0.5625 $$

Doing this for all rows and columns yields an element 1 stiffness matrix of:

$$\mathbf{k^{(1)}}=\begin{bmatrix} \frac{9}{16} & \frac{3\sqrt{3}}{16} & \frac{-9}{16} & \frac{-3\sqrt{3}}{16}\\ \frac{3\sqrt{3}}{16} & \frac{3}{16} & \frac{-3\sqrt{3}}{16} & \frac{-3}{16}\\ \frac{-9}{16} & \frac{-3\sqrt{3}}{16} & \frac{9}{16} & \frac{3\sqrt{3}}{16}\\ \frac{-3\sqrt{3}}{16} & \frac{-3}{16} & \frac{3\sqrt{3}}{16} & \frac{3}{16} \end{bmatrix}

=\begin{bmatrix} 0.563 & 0.325 & -0.563 & -0.325\\ 0.325 & 0.188 & -0.325 & -0.188\\ -0.563 & -0.325 & 0.563 & 0.325\\ -0.325 & -0.188 & 0.325 & 0.188 \end{bmatrix}$$

Note: k(1) was assigned to HW 2 to be filled in with all elements calculated.

Some observations made from seeing the computed element stiffness matrix are as follows,

 * 1) Only 3 numbers need to be computed, the other values only differ by a sign change.
 * 2) Matrix k(1) is symmetric. Thus

$$k_{ij}=k_{ji} \rightarrow   k_{13}=k_{31}  \rightarrow   -0.563=-0.563$$

Observation 2 also means that the transpose of k is the same as k.

To compute element 2, the same steps are taken. Element 2 is at an angle $$\theta ^{(2)}={\color{red}45^{\circ}}$$ Again inputting this angle into the following equations of the director cosines yields:

$$l^{(2)}=cos\theta ^{(2)}=cos45^{\circ} =\frac{\sqrt{2}}{2}=0.707$$

$$m^{(2)}=sin\theta ^{(2)}=sin45^{\circ} =\frac{\sqrt{2}}{2}=0.707$$

Next, to find the stiffness coefficient the below equation is used.

$$k^{(2)}=\frac{E^{(2)} A^{(2)}}{L^{(2)}}=\frac{5*2}{2}=5$$

An example of finding out what each element of the stiffness matrix is shown below.

$$\mathbf{k_{11}}=k^{(2)}*(l^{(2)})^{2}=5*(\frac{\sqrt{2}}{2})^{2}=\frac{5}{2}=2.5 $$

Doing this for all rows and columns yields an element 2 stiffness matrix of:

$$\mathbf{k^{(2)}}=\begin{bmatrix} \frac{5}{2} & \frac{-5}{2} & \frac{-5}{2} & \frac{5}{2}\\ \frac{-5}{2} & \frac{5}{2} & \frac{5}{2} & \frac{-5}{2}\\ \frac{-5}{2} & \frac{5}{2} & \frac{5}{2} & \frac{-5}{2}\\ \frac{5}{2} & \frac{-5}{2} & \frac{-5}{2} & \frac{5}{2} \end{bmatrix}

=\begin{bmatrix} 2.5 & -2.5 & -2.5 & 2.5\\ -2.5 & 2.5 & 2.5 & -2.5\\ -2.5 & 2.5 & 2.5 & -2.5\\ 2.5 & -2.5 & -2.5 & 2.5 \end{bmatrix}$$

Note: k(2) was assigned to HW 2 to be filled in with all elements calculated.

Some observations made from seeing the computed element 2 stiffness matrix are as follows,

 * 1) Only 1 number needs to be computed, the other values only differ by a sign change.
 * 2) Matrix k(2) is symmetric. Thus

$$k_{ij}=k_{ji} \rightarrow   k_{13}=k_{31}  \rightarrow   -2.5=-2.5$$

Observation 2 also means that the transpose of k is the same as k.

title: User:Eml4500.f08.qwiki.bishop/Lecture 7


text:
User:Eml4500.f08.qwiki.bishop/Lecture 11

=Qwiki=

Element 1 Equilibrium
$$\mathbf{f}^{(1)}=\mathbf{k}^{(1)}\mathbf{d}^{(1)}= \begin{bmatrix} 0.5625 & 0.3248 & -0.5625 & -0.3248\\ 0.3248 & 0.1875 & -0.3248 & 0.1875\\ -0.5625 & -0.3248 & 0.5625 & 0.3248\\ -0.3248 & -0.1875 & 0.3248 & 0.1875\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 4.352\\ 6.127\\ \end{bmatrix}= \begin{bmatrix} 0.5625 & 0.3248\\ 0.3248 & 0.1875\\ \end{bmatrix} \begin{bmatrix} 4.325\\ 6.127\\ \end{bmatrix}= \begin{bmatrix} 4.438\\ 2.562\\ \end{bmatrix} $$ $$\mathbf{f}^{(1)}= \begin{bmatrix} f^{(1)}_1\\ f^{(1)}_2\\ f^{(1)}_3\\ f^{(1)}_4\\ \end{bmatrix}= \begin{bmatrix} -4.438\\ -2.562\\ 4.438\\ 2.562\\ \end{bmatrix} $$ Note that:
 * Recall that for Element 1, the local force relationship is given by:
 * To be correct, we must include both the internal and reaction forces of element 1. Since the internal and reaction forces are equal and opposite, the local force matrix for element 1 is given by:
 * $$ f^{(1)}_3 $$,and $$ f^{(1)}_4 $$ are the internal forces of Element 1
 * $$ f^{(1)}_1 $$ and $$ f^{(1)}_2 $$ are reaction forces of Element 1

Observation: Element 1 in Equilibrium We know that Element 1 is in equilibrium because the sum of forces in the x- and y- directions equals zero and the force moment about any point in the element also equals zero. $$\sum F_x = f_1^{(1)} + f_3^{(1)} = -4.438 + 4.438 =0$$ $$\sum F_y = f_2^{(1)} + f_4^{(1)} = -2.562 + 2.562 =0$$ $$\sum M_{any pt} = \sum M_{node1} = -L^{(1)}sin(30)f_3^{(1)} + L^{(1)}cos(30)f_4^{(1)}= -4cos(30)(2.5622) + 4sin(30)4.4378 = -8.867 + 8.867 = 0$$

Element 2 Equilibrium
$$\mathbf{f}^{(2)}=\mathbf{k}^{(2)}\mathbf{d}^{(2)}= \begin{bmatrix} 2.5 & -2.5 & -2.5 & 2.5\\ -2.5 & 2.5 & 2.5 & -2.5\\ -2.5 & 2.5 & 2.5 & -2.5\\ 2.5 & -2.5 & -2.5 & 2.5\\ \end{bmatrix} \begin{bmatrix} 4.352\\ 6.127\\ 0\\ 0\\ \end{bmatrix}= \begin{bmatrix} 2.5 & -2.5\\ -2.5 & 2.5\\ \end{bmatrix} \begin{bmatrix} 4.352\\ 6.127\\ \end{bmatrix}= \begin{bmatrix} f_1^{(2)}\\ f_2^{(2)}\\ \end{bmatrix}= \begin{bmatrix} -4.438\\ 4.438\\ \end{bmatrix} $$
 * Recall for Element 1 and 2 that the x- and y- nodal displacements are equal at their intersecting node. Simply put, $$ d_3^{(1)} = d_1^{(2)} $$ and $$ d_2^{(2)} = d_4^{(1)}$$. As a result, we can express the force-displacement relationship of Element 2 as:

$$\mathbf{f}^{(2)}= \begin{bmatrix} f^{(2)}_1\\ f^{(2)}_2\\ f^{(2)}_3\\ f^{(2)}_4\\ \end{bmatrix}= \begin{bmatrix} -4.438\\ 4.438\\ 4.438\\ -4.438\\ \end{bmatrix} $$
 * To be correct, we must include both the internal and reaction forces of element 2. Since the internal and reaction forces are equal and opposite, the local force matrix for Element 2 is given by:
 * $$ f^{(2)}_1 $$,and $$ f^{(2)}_2 $$ are the internal forces of Element 2
 * $$ f^{(2)}_3 $$ and $$ f^{(2)}_4 $$ are reaction forces of Element 2

Observation: Element 2 in Equilibrium We know that Element 1 is in equilibrium because the sum of forces in the x- and y- directions equals zero and the force moment about any point in the element also equals zero. $$\sum F_x = f_1^{(2)} + f_3^{(2)} = -4.438 + 4.438 =0$$ $$\sum F_y = f_2^{(2)} + f_2^{(2)} = 4.438 - 4.438 =0$$ $$\sum M_{node2} = -L^{(2)}sin(45)f_2^{(2)} + L^{(2)}cos(45)f_1^{(2)}= -2sin(45)(-4.4378) + -2sin(45)(4.4378) = 6.276 - 6.276 = 0$$

Analysis Methods
In general, there are two separate methods that can be used to solve for a 2-bar truss system using statics:

Method 1: FBD Analysis
In this analysis method:
 * Isolate the supports
 * Assign the applied force to only one FBD
 * Examine FBD 1 and FBD 2 Seaparately

Method 2: Nodal Finite Element Analysis
In this analysis method:
 * Isolate the supports AND the nodes
 * Assign the applied force to its respective node
 * Examine Element 1 and Element 2
 * Examine the node independently


text:
User:EML4500.f08.JAMAMA/LectureNotes1

 The material from Wikipedia page was transfered to the Wikiversity page see Submission 1

Arunas Janulevicius --Eml4500.f08.jamama.jan 14:41, 8 December 2008 (UTC)

Click to go back to Homework Postings:Homework_1

Click to go back to Team Jamama's Home Page EML4500.f08.JAMAMA

TOPIC: Course Introduction and Introduction to Wiki
IN CLASS ASSIGNMENT

* Form 5-6 people groups. * Give a name for a group and decide upon the representative (leader) of the group. * Create Wikipedia/Wikiversity account (follow an identified pattern of naming the Wiki accounts). * Share information about the members within the group and present the info to the Instructor/TAs.

How to create the wiki account: use the user account Eml4500.f08.group_name.student_name. The homework will be submitted every Wednesday at 5p.m. Homework consist of:

1. Lecture Notes;

2. Homework Problems;

Directions/specifications upon the report submission:

Every student is responsible for doing at least one problem of the homework assignment + understanding upon how to do the other homework problems. Moreover, the students will be responsible for checking each other's work before the submission time. When submitting, the report material will be sent to the group leader. Each group member should make sure that his/her written part has his/her name associated with it. The group leader will gather all of the reports (including his/her own) and will send the appropriate web page to the TAs and the instructor. The leader will submit the history saved report, not the web page where the report was written. This will prevent the vandalism of the material. Final step is that students will have to evaluate each other anonymously. The homework grade will be assigned for the reports that will be scaled for each student by ratio of : grade_{homework}\frac {points_{evaluation}}{points_}

Plan:

* Vision: Big Picture Mediawiki & Wikipedia:

1. Textbooks >> in comparison of Wikipedia to the Britannica Encyclopedia, it was determined that Wikipedia is at least as accurate as Britannica Encyclopedia while Wikipedia has more recent and sometimes more (quantitavely) material about the subject; 2. Wikiversity >> it is a great place to get acquainted with other Universities' work and the presented material, such as (MIT's Open Course Ware); 3. MIT's Open Course Ware >> the material discussed in classes and the text book material are printed on this Course Ware, so that it could be accessible to entire world. It is especially profitable for the poor countries, where majority of students are not able to purchase the text-books. 4. Old approach >> homework (10%) + 3 exams (30% each) is subjected to change allowing the homework to be weighted more. New approach: homework (40%) + 3 exams (20% each). 5. Confidentiality >> the students will create a certain accounts, which will be known only to the other group members + these accounts should not be used to edit other material on the web for the reasons of the probable vandalism acts. 6. Method of work >> each student is expected to "pull his/her own weight." Every student is responsible for checking each other's work. When submitting, each student should add his/her name upon the material that he/she worked on + no late submissions are accepted (past Wednesday 5 p.m.). 7. e-learning >> e-learning will not be used, since it does not have a capacity to connect to the whole world at any time, it might not allow for the quick/real time peer review of the content, and a student said that e-learning "crashed" on him/her.

* MediaWiki (very important software)

1. Wikiversity, MIT's Open Course Ware >> allows the access to Wikiversity, MIT's Open Course Ware; 2. Collaboration >> allows the effective interation between:

* Member of a team; * Teams in the class; * Professor + student;

TOPIC: Trusses, Matrix Method (Chapter 4)
The following image is of a truss with two elastic (deformable) bars.

Note: The displacement at points 1 and 3 is fixed (constrained) to zero, in both the x and the y direction.

Global Free Body Diagram:

The below image illustrates the 4 unknown reactions. This example is statically indeterminate because it has 3 equations and 4 unknown variables. The key to solving this example is to look at the individual bars' deformation.

2 Free Body Diagrams of Separate Bar Elements

 * Bar Element 1:

The unknown solutions at the nodes are the nodal degrees of freedom. The choice of nodal degrees depend on the governing differential equation.

 * Bar Element 2:

Next step: Force Displacement relationship

Recall:

The force distance relationship of a 1 dimensional spring element (with one end fixed) is F=KD. (K is the spring constant)

The force displacement relationship of a 1D spring with 2 ends free is as shown above. To solve this more complex problem one needs to use a matrix to relate F=Kd. The matrix for this example is shown below.

Stiffness Matrix:

Case 1: Observer sits on node 1.
 * F2=K(d2-d1)

Case 2: Observer sits on node 2, or equilibrium f1+f2=0.
 * F1=-F2=-K(d2-d1)=K(d1-d2)

TOPIC: Steps to Solve a Simple Truss System. (Chapter 1)
1. Global Picture (description)
 * At structure level:
 * Global degrees of freedom (displacement unknowns)
 * Global forces

 * Actually, the displacement Dofs are partitioned into:
 * a known part, e.g., fixed Dof, contraints
 * an unknown part: solved by using the finite element method (FEM)

 * Similarly, for the forces:
 * known part: applied forces
 * an unknown part: reactions

2. Element Picture (draw)
 * Element Dof (displacements)
 * Element forces
 * Note: it can be either in global or local coordiante system

3. Global Force-Displacement (FD) relationships
 * Element stiffness matrix in global coordinates
 * Element force matrices in global coordinates.
 * Assembley of element stiffness matrices and element force matrices into global FD relation: $$K*d$$ = $$F$$

4. Elimination of known Dof to eliminate/reduce the global FD relations (if stiffness matrix is non-singular >> invertable >> det(K) ≠ 0);

Km × m*dm × 1 =  F m × 1, where $$m < n $$ m = n 0 of unknown displacement Dof n = n 0 of known and unknown displacement Dof K is non-singular matix >> K -1 (invertable)>> d m × 1 =  K -1 m × m * F m × 1

5. Compute element forces form now known d >> element stresses

6. Compute the reactions (unknown forces)

Example:

1) Globlal Picture:

Numbering of displacement DOF:
 * Follow the order of global node numbering. Assume x - axes are horizontal: If horizontal force was considered first in the first global node, then in the consequent nodes the horizontal force should be numbered first as well(vertical force follows the horizontal force in each node force/displacement numbering).

Matlab Tutorial
Matlab Tutorial

Contributing Team Members
Megan Alvarez --EML4500.f08.jamama.megan 23:55, 16 September 2008 (UTC)

Justin McIntire --Eml4500.f08.jamama.justin 19:10, 19 September 2008 (UTC)

William Mueller --Eml4500.f08.jamama.mueller 19:12, 19 September 2008 (UTC)

Arunas Janulevicius --Eml4500.f08.jamama.jan 19:51, 19 September 2008 (UTC)

Chris Alford --Eml4500.f08.jamama.chris 19:53, 19 September 2008 (UTC)

Cedric Adam--Eml4500.f08.jamama.adam 20:00, 19 September 2008 (UTC)

title: User:EML4500.f08.JAMAMA/LectureNotes1


text:
User:EML4500.f08.JAMAMA/MatlabTutorial1

To go back to Homework Postings:

To go back to Team JAMAMA's Home Page:

Accessing MATLAB

 * On most systems one can enter Matlab with the command matlab, although on other systems you can access it through a menu or just by clicking an icon.

Entering Matrices

 * Matlab mainly works with a rectangular numerical matrix. All variables represent matrices.

Imaginary numbers can also be entered, using the units i or j.

 * Large amounts of data can easily be loaded using the command load data.ext, where .ext could be any extension. The best files to use are ASCII files.
 * To just create matrices one can just use some of the built in functions.

Individual parts of matrices can be referenced simply by their address. so A(2,3) will select the entry in matrix A, row 2, column 3.

Matrix Operations, Array Operations

 * If the sizes of the matrices your trying to operations on do not coincide with one another an error message will appear, that is unless one of the matrices is a scalar (a 1X1 matrix). A scalar can be used on any size matrix.
 * Also, the division operators are related to one another. Right division is defined in terms of left division by b/A = (A'\b')'.

Matrix operations, array operations

Array Operations

Although addition and subtraction only operate entry-wise, the other operations are matrix operations. Entry-wise will operate on each of the individual elements, while matrix operations operate on the matrices as a whole.

Matrix operations, array operations

Statements, expressions, and variables; saving a session

 * Matlab statements are usually in the simple form of expressions, which are typically composed of operators functions and variable names. When an expression is evaluated it is turned into a matrix with a variable as its name.  If no variable is assigned, a variable ans is created to store that particular matrix.
 * Statements end by pressing enter. They can be continued by putting three or more periods then pressing enter, or can simply be put on one line (but they must be separated by comas or semi-colons).
 * Putting a semicolon at the end of a line makes it so the operation is still done, yet it is not immediately printed.
 * Matlab is case sensitive; A is different than a.
 * The command Who will list all current variables.
 * The command clear can be used before a variable to just delete that one, or used on its own to delete all variables.
 * The permanent variable epsilon (eps) rounds to about 10^-16 on most machines which can be used for converging iterative processes.
 * To stop an unwanted computation without leaving matlab press CTRL-C.

Saving a Session One can hit the save button to store a session as a diskfile with the extension .mat. You can then re-enter Matlab later and use the load function to restore the former workspace.

Matlab Homework Assignment Code

Matrix Operations, Array operations
If sizes of matrices are incompatible with the operator, and error message is shown. The matrix division operators required extra attention. If A is an invertible square matrix and b is a compatible column, resp. row, vector, then

x=A\b is the solution of A*x=b and resp.,

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

Array Operations

The matrix operators of addition and subtraction will work for arrays but the other operators will not. The matix operators can be used to operate entry-wise by placing a period in front of the operator.

Statements, expressions, variables
MATLAB is an expression language where exspression are comprised of operators, functions,and variable names. Expressions are evaluated into matrices and stored as such. Statements are generally terminated with a carriage return but can be continued onto the next line. Also statements can be terminated with a semicolon or period, which suppresses printing of the statement but still carries out the operation. MATLAB is case sensitive. Runaway displays or computation can be halted with CTRL-C.

Saving a session

All variable are lsot when MATLAB is close. Using the save command saves the variables to a .mat file which can later be retrieved with the load command.

Matrix building functions
Some functions in matlab will accomplish predetermined convinient tasks for you.

Here is an example of the of a 5-by-5 matrix(B) created from an original 3-by-3 matrix(A):

disp('5. Matrix Building Function.')

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

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

The result in MatLab is:

5. Matrix Building Function.

A =

 * 1    2     3
 * 4    5     6
 * 7    8     9

B =

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

For, while, if and relations
For

For a given n, the statement

x=[]; for i=1:n, x=[x,i^2],end

will produce a certain n-vector and the statement

x=[]; for i=n:-1:1, x=[x,i^2], end

will produce the same vector in reverse order.

The for statement permits any matrix to be used instead of 1:n.

While

The general form of a while loop is

while relation

statements

end

The statements will be repeated as long as the relation remains true. For example, for a number a, the following will compute the smallest non-negative integer n such that 2^n>a:

n=0;

while 2^n < a

n = n + 1;

end

n

If

The general for of an if statement is

if ''relations

statements''

end

The statement will only be executed if the relation is true. The if function can be branched using the elseif and else functions. For example:

if n < 0

parity = 0;

elseif rem(n,2) == 0

parity = 2;

else

parity = 1;

end

Relations

Many of the relational operators used in MATLAB are used very similar to the operators used in C++ to compare variables. The advantage to using MATLAB for relational operators is when matrices are being used. In a programming language you would need to write a for loop when comparing matrices instead of just a single line of code.

When using these statements, the line of code will return a 0 or 1 representing false and true respectively.

Scalar Functions
Many functions in MATLAB use matrices but some operate on each element in the matrix called scalar functions.

Vector Functions
Vector functions in MATLAB operate on each column of the matrix. So if A is a 3X3 matrix min(A) would return a 1X3 matrix with each value the minimum of their column. If the matrix is only one row but multiple columns such as the return from the min(A) function, the minimum of the row is found and returned by the function. So if the user wanted to find the minimum of a matrix, min(min(a)) should be used so the matrix can be of any size and the desired effect is achieved.

Matrix Functions
MATLAB's most powerful feature is its matrix functions.

Submatrices and Colon Notation
Matrices can be formed by using colon notation instead of writing out the whole matrix. Also a portion of a matrix can be created into its own matrix by using submatrices.

M files
Script Files

Script files consist of normal MATLAB commands in an m-file. To run a script in the working directory in MATLAB, simply type the name of the m-file and all of the lines in the script file will be run.

Function Files
This allows users to create their own custom functions in MATLAB if the existing functions are not enough or if the user would like to modularize their MATLAB program. All variables are local by default (only seen within the function) but can be made global (able to be seen by all functions) by using the global command.

Text string, error messages, and input

In MATLAB variables can be set to string values using single quotes. Also, display messages and error messages for MATLAB programs use the same way of defining string values. Input from users can also be taken in string format and saved in a string type variable.

Managing M-files

Comparing the efficiency of algorithms in MATLAB

When using MATLAB there are many different ways to get to the same result in your program. The program can be made more efficient by changing the way a certain operation is completed for the faster and more efficient way. This can be discovered using flops and the tic toc feature.

Output Format

All of the calculations in MATLAB are done in double precision, but sometimes for certain programs the data needs to be formatted. For instance, if the value returned be a function is an amount of money it only makes sense to show it as 2 decimal places.

Hardcopy

The list of commands can be written to a file using the diary command. Diary can be turned off by typing diary off and then typing diary on when done.

Graphics
MATLAB can make many different graphs and plots including planar plots, 3d line plots, and 3d mesh plots.

Planar plots

Planar plots are the traditional x-y cartesian plotting. In MATLAB this is done by setting a range and interval of point for the x values and the function for the y values. The plot is then created with the plot(x,y) command.

Titles and labels can be added using graph commands.

Axes are automatically set but can be overwritten by using axis commands.

Multiple graphs can be displayed on the same graph using the plot command

MATLAB can also change the style of the line plotted to allow for easier reading of graphs with multiple lines.

3D Line Plots
3-dimensional line plots are extremely similar to the plots previously described for 2-dimensional coordinate systems. The command used to produce a 3D plot is "plot3"; it produces curves in 3D space. If the defined vectors are labeled x, y, and z, then the command would appear as follows: "plot(x, y, z)".

try it

Similar to planar plots, titles and axis labels, the command "axis", may still be used. However, the command "zlabel" needs to be included in order to label the z-axis. Take note, that the "axis" command now requires a 6-vector in order to set the axis scaling to any prescribed limits.

3D Mesh and Surface Plots
The "mesh" command allows the user to plot 3D wire mesh surface plots. "Mesh(z)" draws the 3D perspective plot for the elements in a prescribed matrix z.

In order to graph a 3D surface plot, the program reads the command "surf(z)".

In order to graph a function $$z = f(x,y)$$, over a rectangle, the vectors $$xx$$ and $$yy$$ need to be defined. They provide the partitions of the sides of the rectangle. For the function "meshgrid", matrices 'x' and 'y' must be defined. For matrix 'x', each row equals xx, and the column length equals $$yy$$. For matrix 'y', each column equals $$yy$$.

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

In order to compute the matrix 'z', $$f$$ must be evaluated entrywise over the 'x' and 'y' matrices. "Mesh(z)" or "surf(z)" may be used at this point.

In order to provide color to the surfaces, utilize the "shading" command. The three available options are as follows: "faceted", which is the default shading option, "interpolated", and "flat". These words must be integrated into a full command as follows: "shading faceted", "shading interp", or "shading flat".

 * NOTE: If the command "surf" is used, either of the commands "interpolated" or "flat" will remove all mesh lines.

To change the colors of the different shading options, use the "colormap" command. The options available for "colormap" are as follows: "hsv", which is the default, "hot", "cool", "jet", "pink", "copper", "flag", "gray", and "bone".

If the coordinate system needs to be changed to either cartesian or polar coordinates, the command "view" would be used. This changes the viewpoint from which the 3D object will be seen.

Geometrically defined surfaces can be drawn as well. "Sphere" and "cylinder" are used to generate plots of named surfaces.

 Sparse Matrix Computations

MATLAB always automatically assumes that within any matrix, that any one of the elements may be nonzero. If multiple zeroes do exist, time and memory can be saved by using sparse matrices. If there is a matrix 'A', "nnz(A)" will return only the number of nonzero elements included within that matrix.

By specifying diagonals, a sparse banded matrix can be created rather effortlessly with the usage of the function "spdiags".

Contributing Team Members
Megan Alvarez --EML4500.f08.jamama.megan 23:56, 16 September 2008 (UTC)

William Mueller --Eml4500.f08.jamama.mueller 19:07, 19 September 2008 (UTC)

Justin McIntire --Eml4500.f08.jamama.justin 19:11, 19 September 2008 (UTC)

Arunas Janulevicius --Eml4500.f08.jamama.jan 19:51, 19 September 2008 (UTC)

Chris Alford --Eml4500.f08.jamama.chris 19:54, 19 September 2008 (UTC)

Cedric Adam--Eml4500.f08.jamama.adam 19:59, 19 September 2008 (UTC)

title: User:EML4500.f08.JAMAMA/MatlabTutorial1