Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
What is MATLAB?
MATLAB stands for MATrix LABoratory.
MATLAB is a high-performance language for
technical computing.
Code
Composer
SIMULINK
Simulation
DSP
Processor
Platform
This Presentation
Mathematics
Electronics
Physics
Signal Processing(*)
Development Environment.
MATLAB desktop
Editor and debugger for MATLAB programs (m-files)
Browsers for help, built-in and on-line documentation
Extensive demos
2D and 3D plots
Editing and annotation features
A library that allows you to write C and Fortran programs that interact with
MATLAB.
Graphics.
Help command
help command_name
help [partial_name] tab
Help documents
Demos
January 18, 2005
MATLAB Graphics:
2D Functions (Physics Example)
MATLAB Graphics:
2D Functions (Physics Example)
Planck Radiation Law
3500
kilowatts/sq.meter-micron
3000
3000 K
2700 K
2500 K
2500
2000
1500
1000
500
4
5
6
wavelength microns
10
MATLAB Graphics:
3D Functions (DSP Example)
1
5
9
6
7
2]
A 1 x m or a n x 1 quantity is a vector
[8
6]
A 1 x 1 quantity is a scalar
[8]
MATLAB Plotting
Basic Commands
plot x,y line plots
stem n,y discrete plots (standard
representation of digital signals)
bar vertical bar plots
plot3 3D x,y,z line plots
mesh, surf, etc. 3D surface plots
show_img display matrix as an image
hold hold current figure for multiple line plots
subplot put multiple plots in one figure frame
Etc, etc. - See MATLAB help documentation
January 18, 2005
Scripts
Functions
sumofsines
Use of parameter-controlled data input
loops
fft_plot
Use of MATLAB functions as subroutines
Use of nargin test and branch
January 18, 2005
Mathematics Example:
Polynomial Algebra (Convolution Operator)
20
>> deconv(pc,p2)
ans =
1
3
2
>> deconv(pc,p1)
ans =
1
5
4
4
January 18, 2005
Mathematics Example:
Linear Systems
4 y 3z 2
x y 9 z 60
A*S=B
MATLAB Code:
>> A=[5,-2,-3;0,4,3;1,-1,9];
>> B=[-3,-2,60]'; % Note vector transpose ()
>> S=linsolve(A,B)
S=
1.0000
-5.0000
6.0000
Mathematics Example:
Polynomial Roots
Find the roots of the following system:
y 12 x 2 x 8
MATLAB code:
>> roots([12 -1 -8])
ans =
0.8592
-0.7759
Mathematics Example:
Polynomial Roots
Graphical Solution:
>>
>>
>>
>>
>>
>>
a=12;
b=-1;
c=-8;
x=-1:0.1:1;
y=a*x.^2+b*x+c;
plot(x,y)
A*X = B
>> A=[-7,6;6,-8];
>> B=[5;-10];
>> X=linsolve(A,B)
ans =
1.0000
2.0000
VGS
ID
RS
VGS
I D I DSS 1
VP
Drain Current, Id
0.008
0.006
0.004
0.002
0
-4
-3.5
-3
-2.5
-2
-1.5
Gate-Source Voltage, Vgs
-1
-0.5
Physics Example:
Graphical Solution of a Trajectory
Problem:
A football kicker can give the ball an
initial speed of 25 m/s. Within what
two elevation angles must he kick the
ball to score a field goal from a point
50 m in front of goalposts whose
horizontal bar is 3.44 m above the
ground?
January 18, 2005
Physics Example:
Field Goal Problem
Solution: The general solution is the trajectory equation.
gx 2
y x tan( 0 ) 2
2v0 cos2 ( 0 )
where y = height, x = distance from goal, v0 = take-off
speed, 0 = take-off angle. Given the take-off speed of
25 m/s, the problem requires the solutions for 0 that
result in a minimum height of y = 3.44 m at a distance
of x = 50 m from the goal post. Although an analytical
solution is possible, a graphical solution provides more
physical insight.
January 18, 2005
Physics Example:
Field Goal Problem
>> v0=25;
>> x=50;
>> g=9.8;
>> y=3.44;
>> theta=5:.1:70;
>> theta_r=theta*pi/180;
>> z=y*ones(1,length(theta));
>> zz=x*tan(theta_r)-g*x^2./(2*v0^2*(cos(theta_r)).^2);
>> plot(theta,zz)
>> hold
Current plot held
>> plot(theta,z)
January 18, 2005
Physics Example:
MATLAB Results
n1
n
n 1,3,5,...
h[n]
SINC ( 0 n)
Use of fvtool