Matlab Math-2 2024 2
Matlab Math-2 2024 2
Integration Techniques
Indefinite Integration
Example: x) 3 x 2 + x
f (= syms x f(x) =
f(x)=3*x^2+x
ans =
int(f(x),x)
∫ f (=
x) dx ∫ (3 x 2
+ x) dx
Definite Integration
Example: f (=
x) 3 x 2 + x , [ a, b] = [ −2, 4]
4 4
syms x
∫ f (=
x) dx ∫ (3 x 2
+ x) dx f(x)=
−2 −2
f(x)=3*x^2+x
int(f(x),x,-2,4) ans =
Laplace Transform
Laplace Transform
∞
2
Example: f (t )= π − ∑ sin(nt )
n =1 n
MATLAB-code:
syms x y t
t=linspace(0,2*pi); % A lot of values of f(t) are calculated between t=0 and t=2pi
x=t;
s=3; %Size of series, change accordingly
FourierSeries=0; % Sets the variable to 0 before start
for n=1:s % When s=3 the sum consists of the 3 terms
FourierSeries=FourierSeries+2/n*sin(n*t); % In the example the harmonics are -2/n*sin(nt)
% "-" is incorporated in the
% next line
end
y=pi-FourierSeries; % pi is equal to the dc term in the example,
% values from "FourierSeries" are subtracted according
% to the expression of the Fourier expansion
plot(x,y)
title("n=3") % Value of n (should be changed when s is changed)
xline(0) % coordinate axis
yline(0) % coordinate axis
Math2, Dorthe Wildt Nielsen, SDU, 11th of April, 2024
MATLAB code:
Typing data into data=[x1, x2, …, xn] Choose an appropriate name, commas not
MATLAB: necessary
Example:
data=[7,3,8,6,10,6,2,9,5,8,2,7,1,7]
Histogram hist(data,[1:1:10])
Probability Theory
MATLAB code: