MATLAB is a programming language commonly used in engineering and science applications. It fuses computation, visualization, and programming in an intuitive environment using mathematical notation familiar to engineers. The core data structure in MATLAB is the matrix, and all components can be represented as matrices. MATLAB is widely used in automotive applications such as system modeling, powertrain calibration, vehicle analysis, and generating production code. Basic MATLAB commands include those for clearing variables, closing figures, defining ranges, and commenting code.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
451 views15 pages
MATLAB PPT
MATLAB is a programming language commonly used in engineering and science applications. It fuses computation, visualization, and programming in an intuitive environment using mathematical notation familiar to engineers. The core data structure in MATLAB is the matrix, and all components can be represented as matrices. MATLAB is widely used in automotive applications such as system modeling, powertrain calibration, vehicle analysis, and generating production code. Basic MATLAB commands include those for clearing variables, closing figures, defining ranges, and commenting code.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15
MATLAB
• Fuses components of computation, visualization and programming in intuitive environment
where problems and solutions are expressed in mathematical notation in which WE(Engineers) find familiar. • Abbreviation of MATrix LABoratory. • It’s an interpreted Language. • Heart and Soul is Matrix i.e. each and every component represented in this language is stored in the format of MATRIX. MATLAB in AUTOMOTIVE DOMAIN • System Level Modelling – OEM’s & suppliers created mathematical model to understand behavior of Vehicle system & validate. • Powertrain Calibration & Testing • Vehicle Analysis & Validation – using MATHWORKS for large Data Analysis , NVH Analysis, Driving Testing Analysis • GM created AHS II hybrid Powertrain using MATLAB(Testing, generated Embedded Code) • Volkswagen used AUTOSAR compliant software & integrated with existing ECU • Daimler – designed Tested and generated production code for Mercedes Benz truck . • Many more…. BASIC Commands
• NOTE: Change Directory to your working Directory to avoid unwanted
file search operation Commands Function clc Clears the Comand Window clear all Clears all workspace variable close all Closes all figure window : Defines Range % Line by line Commenting inf infinite NaN Not a Number whos List all the variables in workspace MATLAB Interface Screen • User defined Input • Syntax: var_name = input(‘SOME STRING’)/input(‘SOME STRING’,’s’); • Default data type: Double. • String Display • disp(‘STRING CONTENT’) • fprintf(‘%d string content’) %format specifier can be used like C language • Function handler – similar to inline function in C • Syntax: var_name = @(n) n.^2 • Inbuilt Commands • Ceil , floor ,round ,fix ,sum, min/max, sort • Pre-defined Matrix Functions • Magic(n),eye(n),ones(n),rand(n),zeros(n) • Control Flow statements • For loop • Syntax: for ii=0:10 (MATLAB Commands) end • While loop • Syntax: while (condition) end • Switch Case – accepts int & char values • Syntax • Switch(choice) Case 1 Case 2 Case 3 otherwise • If-else • Syntax: if(condition) • Operation Else M - Files • Their file extension is .m format. • Scripts (Collection of Commands executed in the sequence) • Functions (User Defined Commands which has input and Output) • Vector/Array – 1D matrix (single row , multiple column) • Syntax: var_name = 0:1:10 • Matrix • Syntax: var_name = [1 2 3;4 5 6;7 8 9] • Columns are separated by space or commas. • Rows are separated by semi-colons. • Cells • Collection of Variety Data types • Syntax: var_name = {contents} %Dimensions should be equal. • Indexing Technique • Linear Indexing • Syntax: Matrix_name(1/2/3…N) • Subscipt Indexing • Syntax: Matrix_name(rows,columns) • Matrix Computation • A+B(Matrix Addition), A*B(Matrix Multiplication)…etc • Scalar Computation • Dot operator(.) Matrix_name.^2 • Logical Operator • &&,|| returns logical value as ‘1’ for true and ‘0’ for false • Bitwise Operator • bitand, bitor , bitshift(value,shift_value) where +ve:lshift & -ve:rshift • Relational Operator • >=, <= ,~= , == • Elipses Operator(…) Functions • Syntax: • Function [x1,y1,y2…….yn] = function_name(x1,x2,x3….xn); • Contents in [] are the output variables • Contents in () are the input arguments taken by the function • Function name & file name should be same. • Single function Single file. • Function file should be present in the same directory as that of the script with function call • Solving Polynomial equations, finding their roots • Solving ODE(Ordinary Differential Equation) • Graphical Functions
• DATA Visualization based on the values
• linspace(a,b,n) • Where a: start_value, b = end_value , n:no_of_elements %step_size = (b-a/(n-1)) • Plot(X,Y) • Attributes: • Xlabel(‘’) • Ylabel(‘’) • Title(‘’) • Subplot(X,Y,n) • Where n denotes the numbering of the plot SIMULINK • It’s an add-on to MATLAB that helps to model, analyze and simulate dynamic systems using block diagrams. • Provides Graphical User Interface for constructing Block Diagrams of a System – therefore easy to use • However Modelling a system is Not Necessarily easy ! • Model – Simplified Representation of a System • Need to simulate a Model to study the behavior of a system and to verify the results to our expected result. • Start a Simulink • Type “Simulink” in command prompt. • Click on the GUI icon on the MATLAB toolbar. • Simulink Library BlocK • Sources:
• Sinks:
• Math Operation
• Logic and Bit Operations
• Ports and Subsytem
• Continuous CODE GENERATION • Converting MBD into C, Embedded C