User:Eml4500.f08.Lulz.fisher

Homework 6
Combining the above equations with the following equation:

$$k= \underline{k}^{(i)} = \frac{EA}{L^{(i)}}\begin{bmatrix}1 & -1 \\ -1 & 1 \end{bmatrix}$$

it is possible to determine $$\underline{k}^{(i)}$$ as a function of $$\begin{Bmatrix} A_1, & A_2, & E_1, & E_2, & L^{(i)}\end{Bmatrix}$$

$$k^{(i)}(\tilde{x}) = \frac{[N_1^{(i)}(\tilde{x})E_1 + N_2^{(i)}(\tilde{x})E_2][N_1^{(i)}(\tilde{x})A_1 + N_2^{(i)}(\tilde{x})A_2]}{L^{(i)}} \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$

Problem 4
Let matrix A and matrix B be as follows:

$$A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}$$

$$B = \begin{bmatrix} 7 & 8 & 9 \\ 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}$$

Then matrix $$AB$$ and matrix $$AB^T$$ are as follows:

$$AB = \begin{bmatrix} 21 & 27 & 33 \\ 57 & 72 & 87 \end{bmatrix}$$

$$AB^T = \begin{bmatrix} 21 & 57 \\ 27 & 72 \\ 33 & 87 \end{bmatrix}$$

The matrix $$A^T, B^T and A^TB^T$$ are as follows:

$$A^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}$$

$$B^T = \begin{bmatrix} 7 & 1 & 4 \\ 8 & 2 & 5 \\ 9 & 3 & 6 \end{bmatrix}$$

$$A^TB^T = \begin{bmatrix} 21 & 57 \\ 27 & 72 \\ 33 & 87 \end{bmatrix}$$

Therefore, $$A^TB^T = (AB)^T$$

problem 5
Because the previous equation has been proven for all values of $$W$$ we can choose $$W$$ to be one and hence the equation becomes:

$$k^{(e)}d^{(e)} = f^{(e)}$$

Problem 2
Knowing that $$l^e = cos(\theta)$$ and $$m^e = sin(\theta)$$

$$d_2^e = d_1^e\vec i + d_2^e\vec j$$

$$\tilde d_2^e = \tilde d_1^e\vec\tilde j$$

$$\tilde d_2^e = d_1^e(\vec i*\vec\tilde j) + d_2^e(\vec j*\vec\tilde j)$$

Knowing that $$(\vec i*\vec\tilde j)= -m^e$$ and $$(\vec j*\vec\tilde j)= l^e$$ the following simplification can be preformed.

$$\tilde d_2^e = -m^ed_1^e + l^ed_2^e$$

$$\tilde d_2^e = \begin{bmatrix} -m^e&l^e\end{bmatrix} \begin{bmatrix}d_1^e\\d_2^e\end{bmatrix}$$

Problem 9
Equation 2 is:

$$f_4^1+f_2^2=0$$

Which can also be written as:

$$\begin{bmatrix} k_{41}^1d_1^1+k_{42}^1d_2^1+k_{43}^1d_3^1+k_{44}^1d_4^1 \end{bmatrix}+\begin{bmatrix} k_{21}^2d_1^2+k_{22}^2d_2^2+k_{23}^2d_3^2+k_{24}^2d_4^2 \end{bmatrix}=0$$

The previous equation rewritten using global dof rather then local dof is:

$$\begin{bmatrix} k_{41}^1d_1^1+k_{42}^1d_2^1+k_{43}^1d_3^1+k_{44}^1d_4^1 \end{bmatrix}+\begin{bmatrix} k_{21}^2d_3^2+k_{22}^2d_4^2+k_{23}^2d_5^2+k_{24}^2d_6^2 \end{bmatrix}=0$$

Homework 3
From the previous homework problem we know that:

AC = 6.8324

AB = 1.255

We also know from the notes that the two following equations are true:

$$x_C=AC\cos(\theta)$$

$$y_C=AC\sin(\theta)$$

$$x_B=AB\cos(\theta)$$

$$y_B=AB\sin(\theta)$$

Knowing that for $$(x_b,y_b)$$ $$\theta$$ equals 135 and for $$(x_c,y_c)$$ $$\theta$$ equals 30 the two coordinates are found to be:

$$(x_B,y_B) = (-.887,.887)$$

$$(x_C,y_C) = (5.917,3.416)$$

The coordinates for $$(x_d,y_d)$$ are obtained using the following equation:

$$AD = (x_D - x_A)i + (y_D - y_A)j$$

Which reduces to:

$$AD = (x_D)i + (y_D)j$$

due to point a being at the origin. AD also equals:

$$AD = d_3i +d_4j$$

Knowing that $$d_3 = 4.35$$ and that $$d_4 = 6.127$$ it then can be determined that:

$$(x_D,y_D) = (4.35,6.127)$$

Homework 2
The homework question on page 11-4 of the class notes asked the class to verify the node equation for the following node:



Using the laws of statics ($$\sum $$Fx = 0 and $$\sum $$Fy = 0) we know that sin(30) * p(1)1 must equal sin(45) * p(2)2. We also know that P must equal cos(30) * p(1)1 + cos(45) * p(2)2. These two equations simplify as follows:

$$(1/2)p^1_1 - (\sqrt(2)/2)p^2_2 = 0$$

$$(\sqrt(3)/2)p^1_1 + (\sqrt(2)/2)p^2_2 - P = 0$$

The force P is a known value therefore this is a system of two equations with two unknowns ($$p^1_1, p^2_2)$$. Solving for these unknowns in terms of P gives us:

$$p^1_1 = P/(1/2+\sqrt(3)/2)$$

$$p^2_2 = P/[\sqrt(2)(1/2+\sqrt(3)/2)]$$

Homework 1
Graphics hardcopy

To obtain a hardcopy of the current graphic the command print is used. This command will send the image to the default printer using predefined settings. These settings can be changed by using the printopt command.

The command print followed by a name can be used to print and save the graphic. If the name following the print command does not include a post script the appropriate post script will be assigned to the file. Several graphics can be saved to a single file and printed using the print -append filename command. If the append command is not used on an existing file, the existing file will be overwritten with the new graphic.

Graphics other then the current graphic can be printed and saved by use of the command print -deps -graphic filename. An example of this command is print -deps -f4 Lulz. The previous command will save figure 4 in file Lulz.eps.

3-D line plots

Matlab will produce plots in 3 dimensions using the command plot3. If the X, Y and Z coordinates are the desired coordinates the the command would be as follows, plot3(X,Y,Z). An example of a plot using this command is as follows, t=.01:.01:20*pi; x=cos(t); y=sin(t); z=t.^3; plot3(x,y,z), which creates the following helix:

Image:Spiral3-D.JPG

The axis limits can then be determined using the axis command:

EDU>> axis

ans =

-1          1          -1           1           0      250000

3-D mesh and surface plots [edit]

Mesh plots can be created using the meshcommand. For example the command mesh(x) will create a mesh plot of the predetermined matrix x. Surface plots are created in a similar fashion using the surf command. Just as before the surf(x) command will create a surface plot of the predetermined matrix x.

In order to draw a graph of a function z=f(x,y) it is important to first define xx and yy. These will give partitions of the sides of the rectangle in which the graph is on. Using the command [x,y] = meshgrid(xx,yy); a matrix x and a matrix y are created. Each row of matrix x is equal to xx and it has a column length equal to the length of yy. Each column of matrix y is equal to yy. For example if one wanted to graph z=e-x2-y2 over the square [-2,2]X[-2,2] the code would be as follows: [x,y]=meshgrid(-2:.2:2,-2:.2:2); z=exp(-x.^2-y.^2); mesh(z)

Image:Mesh1.JPG

The shading of the surface plot can be changed with the shading command. The three choices are shading faceted, shading interp, or shading flat. The following is an example of the shading flat command:

Image:Mesh2.JPG

The color of the shading can also be changed using one of the following preset color scheme commands: hsv, hot, cool, jet, pink, copper, flag, grey, or bone. For example colormap(hot) will color the surface plot with the hot color scheme.

Image:Mesh3.JPG

The command view allows one to set how the plot is to be viewed.

Matlab has several preset functions that demonstrate the surface plot feature. I few examples are: peaks, sphere, and cylinder. The following is an example of peaks:

Image:Mesh4.JPG

Handle graphics [edit]

To see the properties of figure 1 enter the command set(1) and gca,set(ans). These properties describe almost all aspects of the plots. This system is called the handle graphics and is further described in the matlab user’s manual.

Part 19: Sparse matrix computations

Matlab is set to assume that any number in a matrix may be a number other then zero. Unfortunately, this assumption cost memory and computing time when it comes to numbers in a matrix that are known to be zero. This is why Matlab has the function sparse available. This function only saves the nonzero components of the matrix saving computing time and memory. For example:

EDU>> f=eye(3)

f =

1    0     0    0     1     0    0     0     1

EDU>> sparse(f)

ans =

(1,1)       1  (2,2)        1  (3,3)        1

EDU>> full(f)

ans =

1    0     0    0     1     0    0     0     1

Notice how the sparse command only shows the nonzero components and the full command shows the entire matrix. One can check the mode of a matrix my entering the command issparse(matrixname). Typically sparse matrix are generated directly rather then applying the command sparse. To do this one would use the command spdiags. For example:

EDU>> m =6; EDU>> n=6; EDU>> e=ones(n,1); EDU>> d=-2*e; EDU>> t=spdiags([e,d,e],[-1,0,1],m,n)

t =

(1,1)      -2  (2,1)        1  (1,2)        1  (2,2)       -2  (3,2)        1  (2,3)        1  (3,3)       -2  (4,3)        1  (3,4)        1  (4,4)       -2  (5,4)        1  (4,5)        1  (5,5)       -2  (6,5)        1  (5,6)        1  (6,6)       -2

The sparse commands for eye, zeros, one, and randn are speye, sparse, spones, and sprandn respectively. Here is an example of each of these commands:

EDU>> speye(3)

ans =

(1,1)       1  (2,2)        1  (3,3)        1

EDU>> sparse(3)

ans =

(1,1)       3

EDU>> spones(3)

ans =

(1,1)       1

EDU>> sprandn(3)

ans =

(1,1)     -0.4326

Using the sparse command one can create a matrix listing only the nonzero components. An example of this is as follows:

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

S =

(1,1)       5  (4,1)        8  (2,2)        6  (4,2)        9  (3,3)        7  (4,3)       10

ans =

5    0     0    0     6     0    0     0     7    8     9    10

Notice that the matrix is displayed both in the sparse mode and the full mode. The following is another example displayed only in the sparse mode.

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

E =

(2,1)       9  (3,2)        2  (4,3)        6  (5,4)        4  (6,5)        8

It is important to note that any operation done on a full matrix will create a full matrix result while any operation done on a sparse matrix will create a sparse matrix result. [[Image:[[Image:Example.jpg]]