Академический Документы
Профессиональный Документы
Культура Документы
http://rsb.info.nih.gov/nih-image/more-docs/Examples/fftexample.gif
http://imagejdocu.tudor.lu/doku.php?id=gui:process:fft
Contents
Introduction to Fourier analysis
Fourier series
Fourier Series
Applications of function fourierseries
Fourier Series
A Fourier series is simply a series expansion of a function that
includes both sine and cosine series. The general form of the
Fourier series expansion in the interval [-L/2,L/2], i.e.,
assuming a period L, is:
and
and
Thus, if c0= -L/2, we recover the first set of equations for an and
b
An.user-defined SCILAB function to calculate Fourier series.
The following function, fourierseries, returns the coefficients
of the Fourier series and the evaluation of the same on a range
of values of x for different number of components. The general
Fourier Series
[a0 a b y] = fourierseries(nn, c0, L, x, f, tol)
where:
nn is a vector containing values of the components to be used,
e.g., nn = [5, 10, 20],
L is the period of the function,
x is a vector indicating the values of x where the Fourier series will
be evaluated,
tol is a tolerance for convergence used in function intg (see -->
help intg).
The integrals defining an and bn are calculated in the interval
[c0,c0+L]. The function returns values a0, a, b, and y, where
a0 is the coefficient a0 in the series,
a and b are vectors containing the coefficients of the cosine and
sine series, respectively, i.e., an and bn for n=1,2,,
y is a matrix with the same number of columns as in vector x and
the number of
Fourier Series
A listing of function fourierseries follows. The function
fourierseries includes a sub-function, fseries, which is
called recurrently to produce the rows of matrix y.
fseries:
ourierseries
HW-10
Note:
Record your intermediate results using Print Screen
Save your results and submit them through your usual way.
AP3114 Overview
Basics
WK 1
Introduction to Scilab, define variables
WK 2
Matrix & Statistics (intro)
Median
WK 3
Programming (if, select, for, while)
WK 4
2D Plots, 3D Plots & Random Numbers
Advanced
WK 6 & 8
WK 10 & 11
equations
WK 12
Solving ODE
WK 10
Linear ordinary differential equations
First order ODE dy/dx=f(x), where f(x)
is a polynomial
WK 11
Review of lecture 1
Creating a variable
Comments (//)/continuation(..)
Elementary mathematical functions
Boolean (%T, %F)
Complex numbers
Integer
Strings (test, +)
Dynamic variables
Matrix
Review of Lecture 2
Element-wise operations: .
Conjugate transpose:
Review of Lecture 3
Looping and branching statements
Branching: if & select/case
Looping: for & while
break: exit/interrupt a loop
continue: to go on to the next loop
Functions
Function Library
genlib = compile *.sci files into binary files and
store them
Load library
21
Flowchart
if
False
Conditi
on?
False Block
select
case
Case 1
True
True Block
Test
expression
Case 2
Case 3
Command
Case 4
for
Given a number
of repetitions
Block 1
while
Condition is True
Block 1
Conditi
on?
False
Block 2
Block 2
Point
plot(1,2,.r)
Bar
bar(x, n1)
Line
plot([1,3],[2,5])
Histgra
m
histplot(n,
data )
Curve
plot(x,y),
Contour
contour(x,y,z,10)
3D plot
Random Number
Solving ODE
WK 10
Linear ordinary differential equations
First order ODE dy/dx=f(x), where f(x)
is a polynomial
WK 11
1) Quadratic equations
ax2+bx+c = 0
The quantity under the square root in this result is known as
the discriminant of the equation, i.e.,
D = b2-4ac.
Possible solutions:
If D>0, the quadratic equation has two distinct real solutions:
x1,2= (-b D1/2)/(2a).
If D=0, the quadratic equation has one real (double) solution,
x1= x2= -b/(2a).
If D<0, the quadratic equation has two conjugate complex
solutions,
x1,2= (-b i(-D)1/2)/(2a),
where i = (-1)1/2 is the unit imaginary number.
2) Cubic equations
2
xy3=+ax
+bx+c = 0
x + a/3 y3+py+q = 0,
p = (3b-a2)/3,
and
q = c + 2a3/27 ab/3.
A discriminant for the reduced cubic
equation is given by
D = (q/2)2+(p/3)3.
An Italian mathematician, Gierolimo
Cardano, proposed the following
solutions to the cubic
equation:
x1= -(a/3)+u+v
x2,3= -(a/3)-(u+v)/2 i3(u-v)/2
If D > 0, one real and two complex conjugate
solutions.
If D = 0, three real solutions including a
double solution (x2 and x3).
D<0
ODE
1)
Solutio
n
where
2)
dy/dx = f(x)
roots(pn
)
x2= x1+h
x3= x2+h
Implicit Method
Ordinary differential equation, dy/dx = g(x,y),
B.C
y(x1) = y1.
Centered difference approximation for dy/dx,
i.e.
dy/dx = (y(x+h)-y(x-h))/(2*h).
With this approximation the ODE becomes,
(y(x+h)-y(x-h))/(2*h) = g(x,y).
In terms of sub-indexed variables, this latter equation can be
written as:
yi-1+2xg(xi,yi)-yi+1= 0, ( i = 2,3, ..., n-1 )
where y(x) = yi, y(x+h) = yi+1, y(x-h) = yi-1, and h = x
Implicit Method
yi-1+2xg(xi,yi)-yi+1= 0, ( i = 2,3, ..., n-1 )
For example, if n = 5, we have 3 equations:
y1+2x g(x2,y2)-y3= 0
y2+2x g(x3,y3)-y4= 0
y3+2x g(x4,y4)-y5= 0
Since y1 is known (it is the initial condition), there are still 4
unknowns, y2, y3, y4, and y5. We use, for example, the forward
difference equation applied to i = 1, i.e.,
(y2-y1)/x = g(x1,y1),
or
y2-x g(x1,y1)-y1= 0.
The values of xi, and n(or x), can be obtained as in the Euler
forward (explicit) solution.
Example
1. Linear Equations
Scilab
2. Free Fall
t=0, v=0,
Case 1. No air resistance
Case 2. Resistance proportional to the lin
ear power of velocity
Case 3. Resistance proportional to the sec
ond power of the velocity
3. Electric Current
V=1; R=1; L=1;
t=0:0.01:6;
i=(V/R)*(1-exp(-R.*t/L));
figure;plot(t,i,'ro');
xlabel('time,
t','fontsize',6),
ylabel('current,
i','fontsize',6)
4. Cantilever Beam
For a uniformly loaded span of a cantilever beam attached to a
wall at x = 0 with the free end at x = L, the formula for the vertic
al displacement from y = 0 under the loaded condition, with y t
he coordinate in the direction opposite that of the load, can be
written as follows:
where
E is a material property known as
the modulus of elasticity;
I is a geometric property of the
cross-section of the beam known
as the moment of inertia; L is the
length; w is the load per unit width
of the beam.
5.
Diffusion equation:
dc
2c
dt
c( x 0, t 0) 1
c( x, t 0) 0
5. Diffusion
dc
2c
dt
t
x 2
x=1:1:100; dt=0.05;
c=zeros(100,1); c(1)=1;
figure;
for t=1:1:3000
for i=2:1:99
d(i)=(c(i+1)+c(i-1)2*c(i))*dt+c(i);
end
d(100)=d(99);
d(1)=1-sum(d(2:100));
c=d;
if pmodulo(t,1000)==0
then plot(x,c);
end
end
Results
t1
c(x,t)
t2
t3
x
P=1/3 3 P=2/3
P=1/3 3 P=2/3
Transition probability