Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Matlab workshop

832 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Matlab workshop

  1. 1. Mohamed Abd Elhay
  2. 2. Mohamed Abd Elahy Embedded SW Engineer Tel./010 9 15 77 828 Email/ mhmd.a.elhay@gmail.com
  3. 3. o MATLAB Desktop. o Simulink o GUI
  4. 4. 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.
  5. 5. The MATLAB Application: 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
  6. 6. 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). Blocksets Toolboxes DAQ cards Instruments Databases and files Financial Datafeeds Stateflow Stateflow Code Generation PC-based real-time systems Desktop Applications Automated Reports
  7. 7. MATLAB Disktop Variable browser Command window Command history
  8. 8. Command window • • • • • • • • save filename load filename who whos clear clc ctrl+c exit or quit % save data from workspace to a file % loads data from file to a workspace % list variables exist in the workspace % list variables in details % clear data stored in the workspace % clears the command window % To abort a command % to quit MATLAB
  9. 9. Variables • Variable name must start with letter. • It is case sensitive. • Hyphen o isvarname X_001 o isvarname if % Check possibility • Max length o namelengthmax % depends on MATLAB version • Variable can’t have the same name of keyword o iskeyword % list all MATLAB keywords
  10. 10. 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;
  11. 11. 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
  12. 12. Plot t=0:0.25:7; y = sin(t); plot(t,y) ; xlabel('x axis'); ylabel('y axis'); title('Heading'); grid on; gtext('text');
  13. 13. IF Condition a= input( ‘A‘ ) if rem(a,2) ==0 msgbox(‘a is even’); else msgbox(‘a is odd’); end Switch case A='bye'; switch A case 'hi' msgbox('he says hi') case 'bye' msgbox('he says bye') otherwise msgbox('nothing') end
  14. 14. IF Condition a= input( ‘A‘ ) if rem(a,2) ==0 msgbox(‘a is even’); else msgbox(‘a is odd’); end Switch case A='bye'; switch A case 'hi' msgbox('he says hi') case 'bye' msgbox('he says bye') otherwise msgbox('nothing') end
  15. 15. For Loop for n = 1:32 r(n) = n; end While Loop x = 1; while (x^2<10) %(Condition) y=x^2; plot(x,y,’or’); hold on x = x+1; end
  16. 16. Statistics Toolbox Statistics 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 Signal Processing
  17. 17. Neural Network Toolbox Neural Networks 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 semiinfinite minimization problems Optimization
  18. 18. 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 Filter Design Toolbox o Control System Toolbox o Financial Toolbox o Data Acquisition Toolbox o Fixed-Point Toolbox o Database Toolbox o Fuzzy Logic Toolbox o Image Processing Toolbox
  19. 19. 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) vs, vc o Signals and systems are simulated over a particular time. 20/14 t
  20. 20. 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)
  21. 21. 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.
  22. 22. C/C++ Java Perl Excel / COM File I/O
  23. 23. COM Excel
  24. 24. oImage a =imread('cameraman.tif'); imshow(a); pixval on; oAudio a =wavread('test.wav'); wavplay(a,44100); Plot(a); oVideo a=aviread('movie.avi'); movie(a);

×