Outils Prog TP PDF
Document Details
Uploaded by WealthyCarnelian2058
MIT
Tags
Summary
This document contains information about MATLAB basics such as the desktop, editor debugger, and command window. Also contains links and information about webinars, MATLAB Central, and getting help.
Full Transcript
MATLAB Basics 14 MATLAB Desktop Current Editor/ Folder Debugger Workspace Command Browser Window Basics of MATLAB MATLAB Basics 15 MATLAB Comman...
MATLAB Basics 14 MATLAB Desktop Current Editor/ Folder Debugger Workspace Command Browser Window Basics of MATLAB MATLAB Basics 15 MATLAB Command History cursor “up” in the command window Basics of MATLAB Introduction 16 Getting Help >>doc http://mathworks.de -> Support -> Product Documentation >>help Search the web F1 Basics of MATLAB Introduction 17 Getting Help – Technical Support http://www.mathworks.com/support/ Basics of MATLAB Introduction 18 Getting Help – Technical Support Contact Support by Email Support Hotline (by the way: Support Engineer at MathWorks DE is a good job opportunity…) http://www.mathworks.de/support/contact_us/ Basics of MATLAB Introduction 19 Getting Help – Bug Report Select product and release http://www.mathworks.com/support/bugreports Basics of MATLAB Introduction 20 MATLAB Central MathWorks online user Group: Exchange of user functions / scripts and add ons Supported by MathWorks employees Newsgroups and Blogs http://www.mathworks.de/matlabcentral/ Basics of MATLAB Introduction 21 MATLAB Central – “Cody” online exercises http://www.mathworks.com/matlabcentral/cody Basics of MATLAB Introduction 22 Webinars MathWorks online Webinars: Demonstration of features Introduction of new capabilities Application examples Live with chat discussion or recorded http://www.mathworks.de/company/events/webinars/index.html Basics of MATLAB Introduction 23 Demos Basics of MATLAB Introduction 24 Trainings The MathWorks offers introductory and intermediate courses in MATLAB®, Simulink®, Stateflow® and Code Generation products, as well as advanced training in specialized applications, such as signal processing, communications and control design. Code Generation Physical Modeling STATEFLOW® - Event-Based Modeling Rapid Prototyping and HIL-Simulation Stateflow® for Logic Driven System Modeling Physical Modeling of Multidomain Fundamentals of Code Generation for Stateflow® for Automotive Applications Systems with Simscape Real-Time Design and Testing Physical Modeling of Mechanical Embedded Systems Systems with SimMechanics Embedded Coder for Production Physical Modeling of Electrical Power Systems with SimPowerSystems Code Generation ® FPGA-Design Generating HDL Code from Simulink® SIMULINK Application-Specific Trainings Simulink® for System and Algorithm Modeling Communications Simulink® for Automotive System Design Communication Systems Modeling Model-Based Design with Simulink® Simulink® Model Management and Simulink® for Aerospace System Design Communication Systems Modeling Architecture with MATLAB® Verification and Validation of Simulink® Models Signal Processing ® Code Integration Integrating Code with Simulink® MATLAB Signal Processing with MATLAB® Signal Processing with Simulink® Image and Video Processing MATLAB® Fundamentals Image Processing with MATLAB® Code Verification MATLAB® Fundamentals for Automotive Polyspace Code Prover for C/C++ Applications Control System Design and Analysis Code Verification MATLAB® Fundamentals for Aerospace MATLAB® and Simulink® for Control Applications Design Acceleration MATLAB® Fundamentals for Financial Applications Statistics Optimization Programming Techniques Statistical Methods in MATLAB® MATLAB® Based Optimization Techniques MATLAB® Programming Techniques Visualization Distributed and Parallel Computing Interactive Applications MATLAB® for Data Processing and Parallel Computing with MATLAB® Building Interactive Applications in MATLAB® Visualization Application Deployment Code Integration Code Generation Deploying MATLAB® Based Applications – Interfacing MATLAB® with C Code MATLAB to C with MATLAB Coder JavaTM Edition Deploying MATLAB® Based Applications –.NET Edition Basics of MATLAB Introduction 25 Stud|Lab TUM Stud|Lab MATLAB student user group Lead by Max Schwenzer and Lucas Lebert Frequently meetings each Monday 13:00 – 14:00 in room MW3618 For Details: [email protected] Reisswolf 03 / 2014 Basics of MATLAB Outline 26 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB MATLAB Basics 27 Exercise: Create a scalar variable: m, n Create a vector: b = (1x4), c = (4x1) Create a matrix: A (4x4) Change the variables Basics of MATLAB MATLAB Basics 28 Workspace Browser Basics of MATLAB MATLAB Basics 29 Data and Variables Class Size Value Name (“variable”) Basics of MATLAB MATLAB Basics 30 Data and Variables Class Size Value Name (“variable”) m*n m*n*…*z Basics of MATLAB MATLAB Basics 31 Data and Variables Class Size Value Name (“variable”) Basics of MATLAB MATLAB Basics 32 Data and Variables Class Size Value Name (“variable”) Basics of MATLAB MATLAB Basics 33 Angermann et al. p. 8 Assignments = assign a value to a variable ; suppress output , separation of commands in one line Reserved Variables pi π i, j √(-1) inf infinity ∞ ans standard output of results (answer) eps floating point accuracy NaN Not a Number (invalid result) Basics of MATLAB MATLAB Basics 34 Angermann et al. p. 9 Mathematical Functions and Operators + - * / ^ Operators exp(x) exponential function mod(x,y) x modulo y log(x) natural logarithm rem(x,y) remainder after division x/y log10(x) common log (basis 10) sqrt(x) square root √x erf(x/√2) normal distribution abs(x) absolute value real(x) real part sign(x) sign imag(x) imaginary part round(x) round conj(x) complex conjugate ceil(x) round up angle(x) phase of a complex value floor(x) round down Trigonometric Functions sin(x) sine tan(x) tangent cos(x) cosine cot(x) cotangent sind(x) sine (x in degree) atan(y/x) arc tangent ± π/2 cosd(x) cosine (x in degree) atan2(y/x) arc tangent ± π/2 Basics of MATLAB MATLAB Basics 35 Angermann et al. p. 12 Vectors and Matrices [x1 x2 … ; x3 x4 …] input of matrices and vectors x1:x2 creation of a line vector [x1 x1+1 x1+2…x2] x1:d:x2 creation of a line vector [x1 x1+d x1+2*d…x2] linspace(x1,x2,n) line vector, start val x1, end val x2, size n, equally distributed logspace(x1,x2,n) line vector, start val x1, end val x2, size n, logarithmically distributed eye(n) nxn identity matrix ones(n) nxn matrix with all entries equal to 1 zeros(n) nxn matrix with all entries equal to 0 rand(x) nxn matrix with random entries between 0 and 1 randn(x) nxn matrix with normally distributed random entries magic(x) nxn matrix constructed from the integers 1 through n^2 with equal row and column sums Basics of MATLAB MATLAB Basics 36 Angermann et al. p. 13 Functions and Operators for Vectors and Matrices * ^ \ operators for matrices and vectors, left division.*.^.\ element wise operators matrix.’, transpose(matrix) transpose matrix ’, ctranspose(matrix) Complex conjugate transpose diff(vector[, n]) n-th difference between adjacent elements of vector conv(vector1, vector2) Convolution and polynomial multiplication Additional functions min(vec) smallest vector element inv(m) matrix inverse max(vec) largest vector element det(m) matrix determinant mean(vec) mean value eig(m) matrix eigenvalues std(vec) standard deviation rank(m) rank sum(vec) sum of vector elements cumsum(v) cumulative sum prod(vec) product of vector cumprod(v) cumulative product elements repmat replicate and tile an array diag(m) diagonals of a matrix sub2ind Linear index from multiple subscripts Basics of MATLAB MATLAB Basics 37 Angermann et al. p. 16 Structs and Cell Arrays struct(‘n1’, w1, ‘n2’, w2, …) create a struct variable Structure.name acess to the element name CellArray = {Value} creation of a Cell Array CellArray{index} = Value creation of a Cell Array cell(n) Creation of a n x n – Cell Array cell(m,n) Creation of a m x n – Cell Array Basics of MATLAB MATLAB Basics 38 Angermann et al. p. 17 Managing Variables size(variable) dimension of a variable length(variable) length of a vector, largest dimension of a matrix clear delete all variables in the workspace clear all also deletes all global variables clear [v1 v2 …] delete selected variables who list all variables that exist in the workspace whos detailed list of all variables in the workspace with name, dimension, data type and size (memory) clc clear command window home moves MATLAB prompt to top of Command Window Basics of MATLAB MATLAB Basics 39 Angermann et al. p. 19 Relational Operators Logical Operators == eq(a,b) equal ~ not(a) logical not ~= ne(a,b) not equal & and(a,b) AND < lt(a,b) less than | or(a,b) OR gt(a,b) greater than (scalar) >= ge(a,b) greater or || Shortcut OR equal than (scalar) Additional Operators all(vec) each element is true any(vec) at least 1 element is true logical(a) type cast to boolean exist(‘x’) existance of x find(vec) index of true elements [~,~,a] = foo(x,y,z) select only 3rd return value Basics of MATLAB MATLAB Basics 40 Brackets {}, () or [] Cell Arrays Indexing Matrix/Vector creation Order of operations Concatenation Argument list Multiple outputs Basics of MATLAB MATLAB Basics 41 The MATLAB Path 1 2 3 >> path(genpath(‘../Folder_Name’),path); Basics of MATLAB MATLAB Basics 42 Exercise: Manipulating Data 1. Create a 4x3 matrix of random numbers Extract the elements at locations 1,2 and 2,3 Extract the element in the lower right Set every value < 0.5 to 0 (use logical indexing) 2. Create a diagonal matrix of size 4x4 with 3 on the diagonal 3. Solve Ax = b for A = magic(3) and b = (1 2 3) Compute eigenvalues of A Basics of MATLAB Outline 43 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB 2D and 3D Plots 44 Visualization Tools – 2D Basics of MATLAB 2D and 3D Plots 45 Visualization Tools – 3D Basics of MATLAB 2D and 3D Plots 46 Angermann et al. p. 46 Graphics : 2D plot commands plot([xvalues,] yvalues…[,plotstyle]) plot, linear axis stairs([xvalues,] yvalues…[,plotstyle]) plot, linear axis, stair step graph bar(…), stem(…) plot, linear axis, bars loglog(xvalues, yvalues…[,plotstyle]) plot, logarithmic axis semilogx(xvalues, yvalues…[,plotstyle]) plot, logarithmic x-axis semilogy(xvalues, yvalues…[,plotstyle]) plot, logarithmic y-axis polar(angle, radius…[,plotstyle]) plot, polar coordinates fplot(function, range) plot, explicit function ezplot(function(x,y)[,range]) plot, implicit function ezplot(function1, function2[,range]) plot, parametric curve hold [on | off] retain current graph in figure Basics of MATLAB 2D and 3D Plots 47 Demo Compute y = sin(2t) + cos(t) where t is from 1 to 10 seconds. Plot y and t >> plot(t, y); >> y_1_min = min(y); >> plot(t, y_1_min); >> hold on; >> y_1_max = max(y); >> plot(t, y); t and y are vectors! Basics of MATLAB 2D and 3D Plots 48 Demo >> x = [0:0.2:20]; >> y = sin(x)./sqrt(x+1); >> y(2,:) = sin(x/2)./sqrt(x+1); >> y(3,:) = sin(x/3)./sqrt(x+1); >> plot(x,y); y is a matrix! Basics of MATLAB 2D and 3D Plots 49 Plotting Tools MATLAB Figure Window Plot Tools Dock Figure in MATLAB Window data plots y-axis x-axis Basics of MATLAB 2D and 3D Plots 50 Data Adjustment Basics of MATLAB 2D and 3D Plots 51 Plots Menu Plots Menu Basics of MATLAB 2D and 3D Plots 52 Plotting from Workspace Browser Context menu of variable or MATLAB menu opens Plot Catalog Basics of MATLAB 2D and 3D Plots 53 Angermann et al. p. 43 Graphics (general) figure [(number)] creation (call) of a figure subplot (line, colum, counter) create a subplot clf clear current figure close number close (delete) figure number close all close (delete) all figures gcf current figure number (Handle) gca current subplot (Handle) get(handle, ‘property’) read object property set(handle, ‘property’, value) set property Basics of MATLAB 2D and 3D Plots 54 Angermann et al. p. 44 Graphics : axis axis([xmin, xmax, ymin, ymax]) manual axis scaling (2D) axis([x1,x2,y1,y2,z1,z2]) manual axis scaling (3D) axis(auto) automatic axis scaling xlim([xmin,xmax]) manual scaling of the x-axis ylim([ymin,ymax]) manual scaling of the y-axis zlim([zmin,zmax]) manual scaling of the z-axis grid [on | off] grid lines on | off zomm [on | off] zooming on | off Graphics : labeling xlabel(string) add x-axis label ylabel(string) add y-axis label zlabel(string) add z-axis label title(string) create title text(x, y, string) place a text on the graph legend(string1, … [,‘location’,…]) create legend Basics of MATLAB 2D and 3D Plots 55 Angermann et al. p. 45 Colors k black r red b blue m magenta c cyan y yellow g green w white Markers. point o circle * asterisk +, x cross Lines - solid line (default) -- dashed line -. dash-dot line : dotted line Basics of MATLAB 2D and 3D Plots 56 Angermann et al. p. 49 Graphics : 3D plot commands [X,Y] = meshgrid(xvector, yvector) rectangular coordinate grid matrix plot3(xvalues,yvalues,zvalues…[,plotstyle]) 3D-plot, points/lines surf(xvalues,yvalues,zvalues…[,color]) 3D-plot, surface mesh(xvalues,yvalues,zvalues…[,color]) 3D-plot, mesh waterfall(xvalues,yvalues,zvalues…[…]) 3D-plot, waterfall contour(xvalues,yvalues,zvalues…[…]) 2D-plot, contour lines/ level curves box [on | off] show box rotate3d [on | off] interactive rotating view(horizontal, vertical) change perpective zlabel(string) z-axis label Color settings colormap(name) choose colormap caxis(color_min, color_max) color scaling Basics of MATLAB 2D and 3D Plots 57 3D Plots >> [X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); >> f = sinc(sqrt((X/pi).^2+(Y/pi).^2)); >> mesh(X,Y,f); >> axis([-10 10 -10 10 -0.3 1]) >> xlabel('{\bfx}') >> ylabel('{\bfy}') >> zlabel('{\bfsinc} ({\bfR})') >> hidden off 3-d plot of a matrix! Try: >> size(f) Basics of MATLAB 2D and 3D Plots 58 3D Plots >> [X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); >> f = sinc(sqrt((X/pi).^2+(Y/pi).^2)); >> surf(X,Y,f); >> axis([-10 10 -10 10 -0.3 1]) >> xlabel('{\bfx}') >> ylabel('{\bfy}') >> zlabel('{\bfsinc} ({\bfR})') >> hidden off Be careful with “copy – paste” of MATLAB plots into PowerPoint slides (file size)! Save plot as image before! Basics of MATLAB Outline 59 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB Data Import and Export 60 Exercise: Consider Global Warming! www.cru.uea.ac.uk/ Basics of MATLAB Data Import and Export 61 Exercise: Is the temperature rising? University of East Anglia, Norwich, UK, Climatic Research Unit Study on global warming Measurement series on combined global land and marine surface temperature record from 1850 to 2013 1. Importing data from HadCRUT4.csv 2. Analyze data 3. Visualizing data as shown on slide before Basics of MATLAB Data Import and Export 62 Exercise: Importing Data from.txt File “Import Data” icon in Workspace window Import Wizard Script Generation List of supported types Basics of MATLAB MATLAB Basics 63 Angermann et al. p. 37 File import and export standard formats load file [variable …] load variables from MAT-File save file [variabel …] safe variables in MAT-File [variable =] load file.ending load from ASCII-File save file.ending –ascii [variable] save variables in ASCII-File variable = xlsread(‘file.xls’) load data from Excel-File xlswrite(‘file.xls’, variable) save data to Excel-File Basics of MATLAB MATLAB Basics 64 Angermann et al. p. 39 Formatted data import and export fid = fopen(‘file.ending’, ‘permission’) open file fclose(fid) close file fprintf(fid, ‘format’, variable[,…]) write formatted data vector = fscanf(fid, ‘format’) read formatted data string = fgetl(fid) read line string = fgets(fid,n) read n characters cellarray = textscan(fid, ‘format’[, number][, ‘parameter’, value, …]) variable = textread(‘file’, ‘format’[, ‘parameter’, value, …]) variable = dlmread(‘file’, ‘delimiter’[, ‘range’]) Basics of MATLAB MATLAB Basics 65 Angermann et al. p. 39 Binary data import and export vector = fread(fid, ‘format’) read data fwrite(fid, matrix, ‘format’) write data uchar, uint16, uint32, uint64 unsigned formats int8, int16, int32, int64 signed formats float32, float64 floating point formats bitN, ubitN, 1 iskeyword 'elseif' 'while' 'end' 'for' 'function' 'global' 'if' 'otherwise' … Basics of MATLAB Programming with MATLAB 72 Angermann et al. p. 21 Conditional execution, control flow and loops if … [elseif …][else] end if-statement switch … case … [otherwise …] end switch-statement for variable=start:stepsize:end for loop commands end while condition commands end while loop Additional intructions: break immediate termination of for or while loop continue immediate jump to the beginning of the next iteration step of a for or while loop return immediate return to invoking function Basics of MATLAB Programming with MATLAB 73 Angermann et al. p. 23 Scripts … continuation sign for line breaks at too long lines % beginning of a comment text line %{ comment %} multiline comment %% beginning of a comment as cell-divider Basics of MATLAB Programming with MATLAB 74 Angermann et al. p. 36 User dialog variable = input(string) request user input for variable variable by displaying the prompt string string = input(string, ‘s’) request user input of a string string = num2str(variable[, format]) convert number to string string = sprintf(string, variable) create formatted string disp(string) display text on screen Escape characters Formatting (conversion characters) \n line break %d signed integer (i.e. 321) \t tabulator %x base 16 (hexadecimal) whole number \\ backslash %5.2f floating point number (i.e. 54.21) %% percent sign % %.2e exponential notation (i.e. 5.42e+001) ‘’ single quotation mark ‘ %s string Basics of MATLAB Programming with MATLAB 75 Angermann et al. p. 40 Operating System calls and file management cd folder change directory pwd show current directory dir [name] list folder contents ls [name] list folder contents mkdir folder create new folder copyfile source destination copy file delete file delete file ! command operating system command system( command ) operating system command with return values eval( string ) interpret string as MATLAB command Basics of MATLAB Programming with MATLAB 76 MATLAB Program Files Why? – Automating – Editing/Debugging – Deploying as applications MATLAB Scripts MATLABFunctions Basics of MATLAB Programming with MATLAB 77 Script Example >> close all >> clear all >> clc >> disp ‘Adjusting path’ >> path(genpath(‘../Folder_Name’),path); >> disp ‘Running Init Files ‘ >> run(‘My_MATLAB_Script’) >> A = ones(5); %Initalization of Variables >> disp ’Init completed, open Simulink Model’ >> open(‘My_Simulink_Model.mdl’) Basics of MATLAB Programming with MATLAB 78 Exercise Plot a sine wave y = sin(t), t=[0:0.1:2*pi] Use for loop to create animation Save MATLAB script as sine_wav_anim.m Basics of MATLAB Programming with MATLAB 79 MATLAB Program Files Why? – Automating – Editing/Debugging – Deploying as applications MATLAB Scripts MATLAB Functions Basics of MATLAB Programming with MATLAB 80 Basics of a MATLAB Program File %% example_foo Dummy function for m-files %% %-----------------------------------------------------------| % function [ x, Y, z ] = example_foo( a, B, c ) %-----------------------------------------------------------| %#codegen % % My helping text about this function % % % COPYRIGHT © 2010, Technische Universität München (TUM) %Everything until here is shwon in F1 help function [ x, Y, z ] = example_foo( a, B, c ) % Main algorithms [~,nB] = size(B); % Assign output values x = 'This is the output ''x''.'; % Just a random string. % Now, Y is calculated. Of course, this is just a dummy calculation Y = ones( length(x), nB ); z = sub_foo(2) + nest_demo_foo(a) + c; % Demo on how to use a subfunction Basics of MATLAB Programming with MATLAB 81 Basics of a MATLAB Program File end % Always finish function with 'end' %% Subfunction demonstration - by the way, this is a 'cell' % This function is not visible to code outside this m-file. It only serves % for strucuring the current file. function [res] = sub_foo(in) res = 2 * in; end %% Nested function demonstration %TODO: Add description here function [res] = nest_demo_foo(m) nest_foo(m); function nest_foo(n) %#ok Just for Demo res = 2*n; end end % --- EOF --- Basics of MATLAB Programming with MATLAB 82 Angermann et al. p. 25 Functions function [out] = name(in) definition of MATLAB function name with list of input parameters in and output values out nargin, nargout number of input / output parameters nargchk(min, max, n) check number n of function parameters, if min graf3d Basics of MATLAB Graphical User Interfaces in MATLAB 89 Using GUI Editor GUIDE Basics of MATLAB Graphical User Interfaces in MATLAB 90 Property Inspector 1 2 Double Click on Element Basics of MATLAB Graphical User Interfaces in MATLAB 91 Figures and Callback Functions Basics of MATLAB Graphical User Interfaces in MATLAB 92 Exchanging Data between GUI, MATLAB and Simulink Write data to MATLAB Workspace: assignin('base',‘Name',Value); Read data from MATLAB Workspace: evalin('base',‘Name'); Use data within GUI (e.g. In Edit Box): set(handles.edit,'String',’Value’); get(hObject,'Value'); Transmit Data to Simulink (e.g. Constant Block): set_param(‘Simulink_Model/Constant','value',… num2str(get(hObject,'Value'))); Receive Data from Simulink (e.g. Constant Block): get_param(‘Simulink_Model/Constant','value‘); Basics of MATLAB Outline Day 1 93 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB Symbolic Math Toolbox 94 Introduction to Symbolic Math Symbolic Math solves the algorithm without numerical discretization (numerical deviation) Not all problems have an analytical solution (e.g. Navier Stokes Equations), in this case numerical methods are required Symbolic Math Toolbox is fully integrated with MATLAB, Simulink and Simscape, allowing analytical solutions to be directly used in other applications (e.g. useful for control systems) Symbolic Math Toolbox is developed and maintained at University of Paderborn Graphical Editor: >> mupad Basics of MATLAB Symbolic Math Toolbox 95 MuPAD Basics Formula Text Evaluate Basics of MATLAB Symbolic Math Toolbox 96 MuPAD Plots Basics of MATLAB Symbolic Math Toolbox 97 MuPAD 3D Animations Basics of MATLAB Symbolic Math Toolbox 98 Workspaces in MuPAD and MATLAB One engine exists for use by Symbolic Math Toolbox called from MATLAB Each notebook also has its own engine MATLAB Workspace Notebook 1 Workspace Notebook 2 Workspace Symbolic Engine Symbolic Engine Symbolic Engine Engine 1 Engine 2 Engine 3 Engine Engine Engine Workspace Workspace Workspace MATLAB and symbolic engine have separate workspaces Each notebook also has a separate workspace Basics of MATLAB Symbolic Math Toolbox 99 Export MuPAD Function to MATLAB Create handle to new Notebook: >> h = mupad; Get function from Notebook: >> y = getVar(h,’general_solution’); Convert symbolic expression to function handle or to file: >> f = matlabFunction(y); >> f = matlabFunction(y, ‘file’, ‘C:\myFctName’); Basics of MATLAB Symbolic Math Toolbox 100 Using MuPAD in MATLAB and Simulink Functions available in the Notebook interface can be called directly from the MATLAB command line Using evalin, it is possible to evaluate a MuPAD expression and return the results to MATLAB Using feval, it is possible to pass symbolic variables that exist in the MATLAB workspace, and these variables are evaluated before being processed in the symbolic engine Creating an Embedded Matlab Block in Simulink >> new_system('sys') >> emlBlock('sys/new_block',y) >> open_system('sys') Basics of MATLAB Outline 101 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB 102 Control System Toolbox and Curve Fitting Toolbox Toolbox Demos Basics of MATLAB Outline 103 Introduction to MATLAB Basics: 1) Introduction 2) MATLAB Basics 3) 2D and 3D Plots 4) Data Import and Export Advanced: 1) Programming with MATLAB 2) Graphical User Interfaces in MATLAB Toolboxes: 1) Symbolic Math Toolbox 2) Control System Toolbox and Curve Fitting Toolbox Basics of MATLAB Additional Information 104 Object-Oriented Programming MATLAB help -> MATLAB -> Advanced Software Development -> Object- Oriented Programming -> Object oriented Design with MATLAB Basics of MATLAB Additional Information 105 Big Data – MapReduce – Hadoop Basics of MATLAB Additional Information 106 External Interfaces Shared libraries (.dll,.so,.dylib) C, C++, Fortran interface C, Fortran MEX-files (.mex) Sun Java classes COM/.NET support Web services Serial Port and other hardware I/O (soft real time) Basics of MATLAB 107 Summary MATLAB is a high level-language for technical computing Interactive tool with mathematical and graphical functions MATLAB provides features to access, compute, analyze and visualize data MATLAB also provides capabilities to interface with external languages Basics of MATLAB