## IN400 - Matlab Lessons

Prof. Simone Cacace
Interests
: Numerical Analysis, Optimal Control, Differential Games, Modeling and Simulation, Computer Graphics

Lessons Diary

• 21/09/2020 (Theory) – Matlab desktop, command window, workspace, current folder, command history, help documentation, window layouts, preferences.
• 24/09/2020 (Theory) – Manage workspace, load/save variables from/to .mat files. Array editor, manual editing of variables. Script editor, basic commands to open/save/modify .m script files.
• 28/09/2020 (Theory) – Strings, scalars, mathematical functions, constants, vectors, matrices. Display format (short/long), assignment (=), arithmetic operations (+ – * / ^), concatenation (, ;), transposition (‘), length, size. Element-wise operations (.* ./ .^), access/modify/delete elements and blocks of elements (: []). Useful matrices (eye, zeros, ones, rand, diag).
• 28/09/2020 (Practice) – Creation and manipulation of vectors and matrices.
• 01/10/2020 (Theory) – Relational operators (< <= > >= == ~=), logic operators (& | ~), logic queries on vectors and matrices (all, any, find). Control flow statements (if…end, if…else…end, if…elseif…else…end, switch…case…end).
• 05/10/2020 (Theory) – Loop statements (while…end, for…end), loop control (break, continue). Anonymous functions ( fun=@(arg list) expression ), primary functions ( function [out list]=name(arg list) … end ), global variables.
• 05/10/2020 (Practice) – Implementation of custom functions using control flow and loop statements.
• 08/10/2020 (Theory) – Matlab Graphics, object hierarchy, parent, children, type, handles. Read/write object properties (get, set), find objects by property value (findobj), copy/delete objects (copyobj, delete). Figure objects, main properties, access current figure (gcf). Axes objects, main properties, access current axes (gca). Line objects, main properties, access current object (gco). Colors, RGB representation. Plotting points and graphs in the plane (plot).
• 12/10/2020 (Theory) – Plot of multiple lines using matrices, line styles, colors, markers, plot of parametric curves, forcing drawing update (drawnow). Measure time (tic, toc), real-time computation (clock, etime).
• 12/10/2020 (Practice) – Exploring features of the plot command for drawing graphs and curves, manipulation of object properties using handles.
• 15/10/2020 (Theory) – Plot of points and parametric curves in the space (plot3), setting azimuth and elevation (view). Additional features of axes objects (grid, hold, [x][y][z]label, title), text objects, axes matrices (subplot). Generation of Cartesian grids from vectors (meshgrid), plot of graphs for functions of two variables (mesh, surf).
• 19/10/2020 (Theory) – Color maps (colormap) and lights (light), main properties. Plot of parametric surfaces in the space, shading (FaceColor) and lighting (FaceLighting). Images (image, imagesc), main properties.
• 19/10/2020 (Practice) – Exploring features of mesh and surf commands for drawing parametric surfaces, using colormaps and images for shading.
• 22/10/2020 (Theory) – Plot of vector fields in 2d and 3d (quiver, quiver3), Forward Euler method for systems of Ordinary Differential Equations, application to the equations of motion of a material point subjected to a force field. Introduction to User Interfaces (uicontrol).
• 26/10/2020 (Theory) – Uicontrol styles (pushbutton, togglebutton, checkbox, edit, slider, popupmenu), properties (Position, String, Value, Callback). Behavior of uicontrols via custom callback functions. Interaction between uicontrols using global variables or (better!) nesting objects in a container function with a common workspace. A complete example script: plot of a parametric surface using uicontrols to affect surface properties, including texture mapping and real-time animation.
• 26/10/2020 (Practice) – Create figures with graphic objects and user interfaces. Use the example script to explore features of uicontrols.
• 29/10/2020 (Theory) – Drawing level-sets of functions and polygons (contour, patch). “Jumping Game”, a complete example of code design, including basic physics with collisions, game logic, user input and graphics.
• 02/11/2020 (Practice) – Concluding remarks, further details on workspaces, global variables, sub-functions, callback functions, graphics primitives, uicontrols, images and surfaces texture mapping.