CTRW MATLAB Toolbox Applied Fractional Calculus Workshop Series
Matlab workshop
-
Upload
- -
Category
Technology
-
view
382 -
download
4
Transcript of Matlab workshop
Mohamed Abd Elhay
o MATLAB Desktop.
o Simulink
o GUI
MATLAB stands for matrix laboratory.
o High-performance language for
technical computing.
o Integrates computation,
visualization, and programming in
an easy-to-use environment where
problems and solutions are
expressed in familiar mathematical
notation.
o Math and computation
o Algorithm development
o Data acquisition
o Modeling, simulation, and prototyping
o Data analysis, exploration, and visualization
o Scientific and engineering graphics
o Application development, including
graphical user interface building
The MATLAB Application:
The MATLAB system have five main parts:
1. Development Environment.
2. The MATLAB Mathematical Function Library.
3. The MATLAB Language.
4. Graphics.
5. The MATLAB Application Program Interface (API).
Code Generation
Blocksets
PC-based real-time systems
Stateflow Stateflow Stateflow Toolboxes
DAQ cards Instruments
Databases and files Financial Datafeeds
Desktop Applications Automated Reports
Variable
browser
Command
window
Command history
MATLAB Disktop
Command window
• save filename % save data from workspace to a file
• load filename % loads data from file to a workspace
• who % list variables exist in the workspace
• whos % list variables in details
• clear % clear data stored in the workspace
• clc % clears the command window
• ctrl+c % To abort a command
• exit or quit % to quit MATLAB
Variables
• Variable name must start with letter.
• It is case sensitive.
• Hyphen o isvarname X_001 % Check possibility
o isvarname if
• Max length o namelengthmax % depends on MATLAB version
• Variable can’t have the same name of keyword o iskeyword % list all MATLAB keywords
Variables
o x= [ 2 4 5 6 77 65] % vector
o x= [ 2,4,5,6,77,65] % same vector
o y= [3 7 5;5 6 3] % matrix 2x3
o startP= 1;endP= 10; number_of_points= 100;
x= linspace (startP, endP, number_of_points)
o step= 0.1;
x= startP : step : endP;
Vectors & matrix operations
min(x); max(x) % minimum; maximum elements
sum(x); prod(x) % summation ; multiplication of all elements
length(x); % return the length of the vector
size(x) % return no. of row and no. of columns
anyVector(end) % return the last element in the vector
find(x==value) % get the indices
[v,e]=eig(x) % eign vectors and eign values
fliplr(x) % flip the vector left-right
Z=X*Y % vectorial multiplication
y= sin(x).*exp(-0.3*x) % element by element multiplication
Plot
t=0:0.25:7;
y = sin(t);
plot(t,y) ;
xlabel('x axis');
ylabel('y axis');
title('Heading');
grid on;
gtext('text');
IF Condition
a= input( ‘A‘ ) if rem(a,2) ==0 msgbox(‘a is even’); else msgbox(‘a is odd’); end
A='bye'; switch A
case 'hi' msgbox('he says hi')
case 'bye' msgbox('he says bye')
otherwise msgbox('nothing')
end
Switch case
IF Condition
a= input( ‘A‘ ) if rem(a,2) ==0 msgbox(‘a is even’); else msgbox(‘a is odd’); end
A='bye'; switch A
case 'hi' msgbox('he says hi')
case 'bye' msgbox('he says bye')
otherwise msgbox('nothing')
end
Switch case
for n = 1:32 r(n) = n;
end
For Loop
x = 1;
while (x^2<10) %(Condition)
y=x^2;
plot(x,y,’or’); hold on
x = x+1;
end
While Loop
Statistics Statistics Toolbox o Contains about 250 functions and GUI’s for:
generating random numbers, probability
distributions, hypothesis Testing, statistical
plots and covers basic statistical functionality
Signal Processing Toolbox o An environment for signal analysis
waveform generation, statistical signal
processing, and spectral analysis
o Useful for designing filters in conjunction with
the image
processing toolbox
Signal Processing
Neural Network Toolbox o GUI for creating, training, and simulating
neural networks.
o It has support for the most commonly used
supervised
Optimization Toolbox o Includes standard algorithms for optimization
o Including minimax, goal attainment, and semi-
infinite minimization problems
Neural Networks
Optimization
Curve Fitting Toolbox o Allows you to develop custom linear and
nonlinear models in a graphical user interface.
o Calculates fits, residuals, confidence intervals,
first derivative and integral of the fit.
Another Tool boxes : o Communications Toolbox
o Control System Toolbox
o Data Acquisition Toolbox
o Database Toolbox
o Image Processing Toolbox
o Filter Design Toolbox
o Financial Toolbox
o Fixed-Point Toolbox
o Fuzzy Logic Toolbox
20/14
o Simulink is a graphical, “drag and drop” environment for building
simple and complex signal and system dynamic simulations.
o It allows users to concentrate on the structure of the problem, rather
than having to worry (too much) about a programming language.
o The parameters of each signal and system block is configured by the
user (right click on block)
o Signals and systems are simulated over a particular time.
vs, v
c
t
o .fig
MATLAB Figure
o .m
MATLAB function, script, or class
o .mat
MATLAB binary file for storing variables
o .mex MATLAB executable (platform specific, e.g. ".mexmac" for the Mac, ".mexglx" for Linux)
o GUIDE : stores GUIs in two files, which are generated the
first time you save or run the GUI:
.fig file :
Contains a complete description of the GUI
figure layout and the components of the GUI,
Changes to this file are made in the Layout
Editor.
.m file :
Contains the code that controls the GUI, You
can program the callbacks in this file using
the M-file Editor.
Excel COM
a =imread('cameraman.tif'); imshow(a); pixval on;
a =wavread('test.wav');
wavplay(a,44100);
Plot(a);
a=aviread('movie.avi'); movie(a);
oImage oVideo oAudio