Computational Project for MATLAB: Defining Vectors, Matrices, and Plotting Functions - Pro, Study Guides, Projects, Research of Mechanical Engineering

A computational project for creating matlab m-files to define vectors and matrices using loops and vector operations, as well as plotting functions and their derivatives using the symbolic math toolbox. The project includes tasks such as creating subplots, 3-dimensional surface plots, and filled contour plots.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 02/10/2009

koofers-user-1cv
koofers-user-1cv 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computational Project # 1
Due February 12
1. Develop, debug, and test a program (MATLAB m-file) that for arbitrary m and n (input
parameters):
a) Defines vector 1,1,
1
i
i
x
i
m
==
m
using single loop.
b) Define vector
(
)
1
11cos , 1,
21
j
j
y
n
π


=− =





jn
using Matlab vector
operations instead of using loop.
c) Define two-dimensional array
()
2
1sin , 1, , 1,
2
ij i j
yi mj
π

=− = =


ax using double loop.
n
d) Define two-dimensional array
44
12
,1,, 1,
43
ij i j
y i mj

=−+− = =

 ……
bx
using “meshgrid” Matlab command instead of using double loop.
n
e) Use subplot command to break the figure window into a 2-by-2 matrix of smaller
sub-windows.
f) Plot y vs. x in first sub-window if n=m, otherwise create an empty figure with axes
and domain size defined x and y vectors and write an error message “Error: n/=m”.
Define the names for the axes using on-line commands and the figure title. Create
legends.
g) Plot two-dimensional array aij as 3-dimensional surface. Use two different styles for
the surface: “shading interp” and “shading faceted” for two other sub-windows.
h) In the forth sub-winow create a filled contour plot of two-dimensional array bij. Use
jet as a colormap.
For items (a)-(g) create a single function that performs all the tasks with n and m as input
parameters. Run and test the program for (n,m)=(11,11), (21,11) .
2. Using the Symbolic Math Toolbox create, debug, and test another program (MATLAB
m-file) that
a) finds first 5 terms of Taylor series expansion for
()
2
cos tan 4
x
x
π

about x=0.
b) differentiates the function
()
2
sin
tan sin( ) x
x
e
P.S. Email your code to [email protected]. The program that you send should be a
working program All the codes will be checked whether they run or not. If they are erroneous,
but run, points will be taken for the errors. If the code is not running (it has some syntax
errors), an additional 25% will be taken out. The goal of this class is for you to be comfortable
solving engineering problems. Please take your time and learn how to trust the computer.

Partial preview of the text

Download Computational Project for MATLAB: Defining Vectors, Matrices, and Plotting Functions - Pro and more Study Guides, Projects, Research Mechanical Engineering in PDF only on Docsity!

Computational Project # 1

Due February 12

  1. Develop, debug, and test a program (MATLAB m-file) that for arbitrary m and n (input parameters):

a) Defines vector

i

i x i m

m using single loop.

b) Define vector

1 cos , 1, 2 1 j

j y n

 ^ − 

jn using Matlab vector

operations instead of using loop. c) Define two-dimensional array

2 1 sin , 1, , 1, 2

ij i^ π y^ j i^ m^ j

= ^ −  = =

a x … … n using double loop.

d) Define two-dimensional array

4 4 1 2 , 1, , 1, 4 3

ij i y^ j i^ m^ j

= ^ − ^ + ^ −  = =

b x … …

using “meshgrid” Matlab command instead of using double loop.

n

e) Use subplot command to break the figure window into a 2-by-2 matrix of smaller sub-windows. f) Plot y vs. x in first sub-window if n=m , otherwise create an empty figure with axes and domain size defined x and y vectors and write an error message “Error: n /= m ”. Define the names for the axes using on-line commands and the figure title. Create legends. g) Plot two-dimensional array aij as 3-dimensional surface. Use two different styles for the surface: “ shading interp ” and “ shading faceted ” for two other sub-windows. h) In the forth sub-winow create a filled contour plot of two-dimensional array bij. Use jet as a colormap. For items (a)-(g) create a single function that performs all the tasks with n and m as input parameters. Run and test the program for ( n,m )=( 11,11 ), ( 21,11 ).

  1. Using the Symbolic Math Toolbox create, debug, and test another program (MATLAB m-file) that

a) finds first 5 terms of Taylor series expansion for cos ( 2 )tan

x x

 about^ x=.

b) differentiates the function ( )

sin^2 tan sin( ) x e x

P.S. Email your code to [email protected]. The program that you send should be a working program All the codes will be checked whether they run or not. If they are erroneous, but run, points will be taken for the errors. If the code is not running (it has some syntax errors), an additional 25% will be taken out. The goal of this class is for you to be comfortable solving engineering problems. Please take your time and learn how to trust the computer.