


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Lab; Professor: Nasseri; Class: SpTp-Engineering Computations; Subject: Mechanical Engineering Tech; University: Southern Polytechnic State University; Term: Unknown 1989;
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Lab 7 Practice Problems Engineering Computation, Dr S. Nasseri
Try these:
length(C) = 8
diff(A)
length(diff(C))
Consider the following matrix A. Try the diff command for this matrix:
, >>diff (A) =?
Without typing “help diff”, try theses ones for the same matrix A and guess what each does (these
commands have applications in signal processing):
Af1= diff(A, 1)
First order difference along the first
dimension (Matlab does all the operations on
column by default, or you can say the operation
of row differences)
Af2 = diff(A, 2)
Second order difference along the first
dimension (Considers the diff(A,1)). This is
again the operation of row differences.
Af11 = diff(A,1,1)
First order difference along the first
dimension (the operation of row differences).
Af22= diff (A,1,2)
First order difference along the second
dimension (the operation of column differences.)
Af12 = diff(A,2,1)
Second order difference along the first
dimension (the operation of row differences)
Af22 = diff (A,2,2)
Empty matrix: 5-by-
Second order difference along the second
dimension (the operation of column
differences.). Since we have only one column, it
returns an empty matrix.
Try to use syms ‘x’ and differentiate the following functions:
Example:
2 cos x (^) :
syms 'x' % or x = sym('x')
y= cos(x)^2; % you don’t place. before ^
diff(y,x) % derivative of y with respect to x
ans =
-2cos(x)sin(x)
2 -x
2
e y=
x 3 x x
syms 'x'
y= exp(-x^2)/(x^2 - 3*x + sqrt(x))
y =
exp(-x^2)/(x^2-3*x+x^(1/2))
diff(y,x)
ans =
-2xexp(-x^2)/(x^2-3x+x^(1/2))-exp(-x^2)/(x^2-3x+x^(1/2))^2(2x-3+1/2/x^(1/2))
Which is:
2 2
(^2 )
2
x x
2 2
y=
cos x sin x
syms 'x'
y=1/(cos(x^2)+sin(x^2))
y =
1/(cos(x^2)+sin(x^2))
diff(y,x)
ans =
-1/(cos(x^2)+sin(x^2))^2(-2sin(x^2)x+2cos(x^2)*x)
2 2
y=
cos x x .sin x
syms 'x'
y = 1/(cos(x^2)+sqrt(x)*sin(x^2))
y =
1/(cos(x^2)+sin(x^2)*x)
diff(y,x)
ans =
-1/(cos(x^2)+x^(1/2)sin(x^2))^2(-2sin(x^2)x+1/2/x^(1/2)sin(x^2)+2x^(3/2)*cos(x^2))
1 1.5 2 2.5 3 3.
-0.
-0.
-0.
-0.
0
1
Backward
Forward
Central