{"id":5320,"date":"2016-10-29T06:54:20","date_gmt":"2016-10-29T06:54:20","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=5320"},"modified":"2018-11-07T19:28:51","modified_gmt":"2018-11-07T19:28:51","slug":"matlab-cheatsheet","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=5320","title":{"rendered":"MATLAB Cheatsheet"},"content":{"rendered":"<p><a href=\"https:\/\/www.uni-due.de\/ingmath\/download\/norek\/matlab_kurz.pdf\">Matlab-Schnelleinf \u0308uhrung<\/a>, PDF, 3 Seiten<\/p>\n<h3>Formatting<\/h3>\n<h4>Number<\/h4>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/format.html\"><code>format<\/code><\/a>, Set Command Window output display format<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt;&gt; a = 1\/3;\r\n&gt;&gt; b = 0.001;\r\n\r\n&gt;&gt; format short\r\na = 0.3333\r\nb = 1.0000e-03\r\n\r\n&gt;&gt; format shortE\r\na = 3.3333e-01\r\nb = 1.0000e-03\r\n\r\n&gt;&gt; format shortG\r\na = 0.33333\r\nb = 0.001\r\n\r\n&gt;&gt; format shortEng\r\na = 333.3333e-003\r\nb = 1.0000e-003\r\n\r\n&gt;&gt; format long\r\na = 0.333333333333333\r\nb = 1.000000000000000e-03\r\n\r\n&gt;&gt; format longE\r\na = 3.333333333333333e-01\r\nb = 1.000000000000000e-03\r\n\r\n&gt;&gt; format longG\r\na = 0.333333333333333\r\nb = 0.001\r\n<\/pre>\n<h4>Strings<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/formatting-strings.html\">Functions That Format Data into Text<\/a><\/p>\n<ul>\n<li><code>compose <\/code>\u2014 Write arrays of formatted data to an output string array<\/li>\n<li><code>sprintf <\/code>\u2014 Write formatted data to an output character vector or string scalar<\/li>\n<li><code>fprintf <\/code>\u2014 Write formatted data to an output file or the Command Window<\/li>\n<li><code>warning <\/code>\u2014 Display formatted data in a warning message<\/li>\n<li><code>error <\/code>\u2014 Display formatted data in an error message and abort<\/li>\n<li><code>assert <\/code>\u2014 Generate an error when a condition is violated<\/li>\n<li><code>MException <\/code>\u2014 Capture error informatio<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nstr = sprintf('Hello, %d worlds!', 20)\r\ndisp(sprintf('Hello, %d worlds!', 20))\r\n\r\n% write to Command Window\r\nfprintf('%5d %5d %5d %5d\\n', A(1:4))\r\n\r\n% write to file\r\nfileID = fopen('myfile.txt','w');\r\nnbytes = fprintf(fileID,'%5d %5d %5d %5d\\n', A(1:4))\r\n<\/pre>\n<h3>Matrix<\/h3>\n<p><a href=\"https:\/\/itp.tugraz.at\/LV\/kernbich\/AppSoft-1\/appsoft1\/node21.html\">Erzeugung von Matrizen<\/a><\/p>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/eye.html\"><code>eye<\/code><\/a>, Identity matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/ones.html\">ones<\/a>, Create array of all ones<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/zeros.html\">zeros<\/a>, Create array of all zeros<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&gt;&gt; C = &#x5B; 1 2 4 4 5; 6 7 8 9 10];\r\nC =\r\n     1     2     3     4     5\r\n     6     7     8     9    10\r\n\r\n&gt;&gt; size(C)\r\n     2     5\r\n\r\n&gt;&gt; length(C)\r\n     5\r\n\r\n=================================\r\n\r\n&gt;&gt; E = &#x5B; 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8; 5 6 7 8 9]\r\nE =\r\n     1     2     3     4     5\r\n     2     3     4     5     6\r\n     3     4     5     6     7\r\n     4     5     6     7     8\r\n     5     6     7     8     9\r\n\r\n&gt;&gt; E(3,2)\r\n     4\r\n\r\n&gt;&gt; E(3,(2:5))\r\n     4     5     6     7\r\n\r\n&gt;&gt; E((3:4),(2:5))\r\n     4     5     6     7\r\n     5     6     7     8\r\n<\/pre>\n<h3>Plotting<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nplot(x-values, y-values);\r\nloglog(x-values, y-values);\r\nsemilogx(x-values, y-values);\r\n\r\nxlabel('\\omega in Hz');\r\nylabel('H_d_B');\r\n\r\naxis(&#x5B;x-min x-max y-min y-max]);\r\n\r\ngrid on;\r\ngrid off;\r\n\r\nhold on;\r\nhold off;\r\n\r\n<\/pre>\n<h3>Default Argument<\/h3>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/795823\/default-arguments-in-matlab\">Default Arguments in Matlab<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nfunction f(arg1,arg2,arg3)\r\n\r\n  if nargin &lt; 3\r\n    arg3 =   'some default'\r\n  end\r\n\r\nend\r\n<\/pre>\n<h3>LaTex<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nset(groot, 'defaultAxesTickLabelInterpreter',   'latex');\r\nset(groot, 'defaultLegendInterpreter',          'latex');\r\nset(groot, 'defaultTextInterpreter',            'latex');\r\n<\/pre>\n<h3>Object-Oriented-Programming (OOP)<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/de\/discovery\/object-oriented-programming.html\">Objektorientiertes Programmieren in MATLAB<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/de\/company\/newsletters\/articles\/introduction-to-object-oriented-programming-in-matlab.html\">Einf\u00fchrung in die Objekt-Orientierte Programmierung mit MATLAB<\/a><\/p>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/object-oriented-programming.html\">Object-Oriented Programming<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/create-a-simple-class.html\">Create a Simple Class<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/class-components.html\">Class Components<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/class-syntax-guide.html\">Class Syntax Guide<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/modifying-and-reloading-classes.html\">Automatic Updates for Modified Classes<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/handle-class-destructors.html\">Handle Class Destructor<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/class-constructor-methods.html\">Class Constructor Methods<\/a><\/p>\n<p><a href=\"https:\/\/www.cs.ubc.ca\/~murphyk\/Software\/matlabTutorial\/html\/objectOriented.html\">Object Oriented Programming in Matlab: basics<\/a><\/p>\n<h4>Value Class vs. Handle Class<\/h4>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/272618\/how-to-modify-properties-of-a-matlab-object\">How to modify properties of a Matlab Object<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/comparing-handle-and-value-classes.html\">Comparison of Handle and Value Classes<\/a><\/p>\n<h4>Callbacks<\/h4>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/creating_guis\/write-callbacks-using-the-programmatic-workflow.html\">Write Callbacks for Apps Created Programmatically<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/class-methods-for-graphics-callbacks.html\">Class Methods for Graphics Callbacks<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/listener-callback-functions.html\">Listener Callback Syntax<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/callback-execution.html\">Callback Execution<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/creating-a-function-handle.html\">Create Function Handle<\/a> (Procedural)<\/p>\n<h4>Overload Methods<\/h4>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/7217653\/how-to-overload-user-defined-functions-in-matlab\">How to overload user defined functions in Matlab?<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_oop\/implementing-operators-for-your-class.html\">Operator Overloading<\/a><\/p>\n<h3>Objects<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/use-a-matlab-timer-object.html\">Use a MATLAB Timer Object<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/timer-class.html\"><code>timer class<\/code><\/a>, Create object to schedule execution of MATLAB commands<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/timer-callback-functions.html\">Timer Callback Functions<\/a><\/p>\n<h3>Functions<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/integral.html\"><code>integral<\/code><\/a>, Numerical integration<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/num2str.html\"><code>num2str<\/code><\/a>, Convert numbers to character array<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/patch.html\"><code>patch<\/code><\/a>, Create one or more filled polygons<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/roots.html\"><code>roots<\/code><\/a>, Polynomial roots (Nullstellen des Polynoms)<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fzero.html\"><code>fzero<\/code><\/a>, Root of nonlinear function<\/p>\n<p>Array<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/setdiff.html\"><code>setdiff<\/code><\/a>, Set difference of two arrays<\/p>\n<p>Variables<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/varargin.html\"><code>varargin<\/code><\/a>, Variable-length input argument list<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/exist.html\"><code>exist<\/code><\/a>, Check existence of variable, script, function, folder, or class<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/varargin.html\"><code>varargin<\/code><\/a>, Variable-length input argument list<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/nargin.html\"><code>nargin<\/code><\/a>, Number of function input arguments<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/loren\/2009\/05\/05\/nice-way-to-set-function-defaults\/\">Nice Way to Set Function Defaults<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/answers\/217363-how-to-support-default-parameter-in-matlab-function\">How to support default parameter in MATLAB FUNCTION ?<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nfunction y = somefun2(a,b,opt1,opt2,opt3)\r\n    % Some function with 2 required inputs, 3 optional.\r\n\r\n    % Check number of inputs.\r\n    if nargin &gt; 5\r\n        error('myfuns:somefun2:TooManyInputs', ...\r\n            'requires at most 3 optional inputs');\r\n    end\r\n\r\n    % Fill in unset optional values.\r\n    switch nargin\r\n        case 2\r\n            opt1 = eps;\r\n            opt2 = 17;\r\n            opt3 = @magic;\r\n        case 3\r\n            opt2 = 17;\r\n            opt3 = @magic;\r\n        case 4\r\n            opt3 = @magic;\r\n    end\r\nend\r\n\r\nfunction y = somefun2Alt(a,b,varargin)\r\n    % Some function that requires 2 inputs and has some optional inputs.\r\n\r\n    % only want 3 optional inputs at most\r\n    numvarargs = length(varargin);\r\n    if numvarargs &gt; 3\r\n        error('myfuns:somefun2Alt:TooManyInputs', ...\r\n            'requires at most 3 optional inputs');\r\n    end\r\n\r\n    % set defaults for optional inputs\r\n    optargs = {eps 17 @magic};\r\n\r\n    % now put these defaults into the valuesToUse cell array, \r\n    % and overwrite the ones specified in varargin.\r\n    optargs(1:numvarargs) = varargin;\r\n    % or ...\r\n    % &#x5B;optargs{1:numvarargs}] = varargin{:};\r\n\r\n    % Place optional args in memorable variable names\r\n    &#x5B;tol, mynum, func] = optargs{:};\r\n    \r\nend\r\n<\/pre>\n<p>Try\/Catch and Exception<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/try.html\"><code>try, catch<\/code><\/a>, Execute statements and catch resulting errors<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/throw-an-exception.html\">Throw an Exception<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/mexception.throw.html\"><code>throw<\/code><\/a>, Throw exception<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/error.html\"><code>error<\/code><\/a>, Throw error and display message<\/p>\n<p>Complex number<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/real.html\"><code>real<\/code><\/a>, Real part of complex number<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/imag.html\"><code>imag<\/code><\/a>, Imaginary part of complex number<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/conj.html\"><code>conj<\/code><\/a>, Complex conjugate<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/angle.html\"><code>angle<\/code><\/a>, Phase angle<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/abs.html\"><code>abs<\/code><\/a>, Absolute value and complex magnitude<\/p>\n<p>isType<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/is.html\"><code>is<\/code><\/a>, Detect state<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/isscalar.html\"><code>isscalar<\/code><\/a>, Determine whether input is scalar<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/ismatrix.html\"><code>ismatrix<\/code><\/a>, Determine whether input is matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/isnumeric.html\"><code>isnumeric<\/code><\/a>, Determine if input is numeric array<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/isempty.html\"><code>isempty<\/code><\/a>, Determine whether array is empty<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/isnan.html\"><code>isnan<\/code><\/a>, Array elements that are NaN<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/iscell.html\"><code>iscell<\/code><\/a>, Determine whether input is cell array<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/istable.html\"><code>istable<\/code><\/a>, Determine whether input is table<\/p>\n<p>Symbolic Toolbox<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/symbolic\/fplot.html\"><code>fplot<\/code><\/a>, Plot symbolic expression or function<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/symbolic\/subs.html\"><code>subs<\/code><\/a>, Symbolic substitution<\/p>\n<p>Window<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/figure.html\"><code>figure<\/code><\/a>, Create figure window<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/gcf.html\"><code>gcf<\/code><\/a>, Current figure handle<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/clf.html\"><code>clf<\/code><\/a>, Clear current figure window<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/groot.html\"><code>groot<\/code><\/a>, Graphics root object<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/findobj.html\"><code>findobj<\/code><\/a>, Locate graphics objects with specific properties<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/set.html\"><code>set<\/code><\/a>, Set graphics object properties<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/get.html\"><code>get<\/code><\/a>, Query graphics object properties<\/p>\n<pre class=\"brush: plain; title: Get\/Set current figure; notranslate\" title=\"Get\/Set current figure\">\r\nset(0, 'CurrentFigure', figureHandle)\r\nfig = get(groot,'CurrentFigure');\r\n<\/pre>\n<p>2D Plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/linspace.html\"><code>linspace<\/code><\/a>, Generate linearly spaced vector<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/plot.html\"><code>plot<\/code><\/a>, 2-D line plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/scatter.html\"><code>scatter<\/code><\/a>, Scatter plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/stem.html\"><code>stem<\/code><\/a>, Plot discrete sequence data<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/line.html\"><code>line<\/code><\/a>, Create primitive line<\/p>\n<p>3D Plot \/ Mesh<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/plot3.html\"><code>plot3<\/code><\/a>, 3-D line plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/scatter3.html\"><code>scatter3<\/code><\/a>, 3-D scatter plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/quiver3.html\"><code>quiver3<\/code><\/a>, 3-D quiver or velocity plot<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/meshgrid.html\"><code>meshgrid<\/code><\/a>, 2-D and 3-D grids<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/contour.html\"><code>contour<\/code><\/a>, Contour plot of matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fill3.html\"><code>fill3<\/code><\/a>, Filled 3-D polygons<br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/13464304\/how-can-i-plot-a-3d-plane-in-matlab\">How can I plot a 3D-plane in Matlab?<\/a><\/p>\n<p>Axis<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/gca.html\"><code>gca<\/code><\/a>, Current axes or chart<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/cla.html\"><code>cla<\/code><\/a>, Clear axes<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/subplot.html\"><code>subplot<\/code><\/a>, Create axes in tiled positions<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/hold.html\"><code>hold<\/code><\/a>, Retain current plot when adding new plots<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/axis.html\"><code>axis<\/code><\/a>, Set axis limits and aspect ratios<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/xlim.html\"><code>xlim<\/code><\/a>, Set or query x-axis limits<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/xlabel.html\"><code>xlabel<\/code><\/a>, Label x-axis<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/legend.html\"><code>legend<\/code><\/a>, Add legend to axes<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/daspect.html\"><code>daspect<\/code><\/a>, Control data unit length along each axis<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/pbaspect.html\"><code>pbaspect<\/code><\/a>, Control relative lengths of each axis<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/creating_plots\/aspect-ratio-for-2-d-axes.html\">Control Ratio of Axis Lengths and Data Unit Lengths<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/visualize\/manipulating-axes-aspect-ratio.html\">Manipulating Axes Aspect Ratio<\/a><\/p>\n<pre class=\"brush: plain; title: Grid; notranslate\" title=\"Grid\">\r\ngrid on;     % Nur grobe Linien einschalten\r\ngrid minor;  % Nur feine Linien einschalten\r\n\r\n% Entweder\r\nax = gca;\r\nax.GridColorMode = 'manual';\r\nax.GridAlphaMode = 'manual';\r\nax.GridColor     = &#x5B;0.0, 1.0, 0.0];\r\nax.GridAlpha     = 1.0;\r\n\r\nax.MinorGridColorMode = 'manual';\r\nax.MinorGridAlphaMode = 'manual';\r\nax.MinorGridColor     = &#x5B;1.0, 0.0, 0.0];\r\nax.MinorGridAlpha     = 0.4;\r\n\r\n% Oder\r\nset(gca, 'GridColorMode', 'manual');\r\nset(gca, 'GridAlphaMode', 'manual');\r\nset(gca, 'GridColor', &#x5B;0.0, 1.0, 0.0]);\r\nset(gca, 'GridAlpha', 1.0);\r\n\r\n<\/pre>\n<pre class=\"brush: plain; title: Legend; notranslate\" title=\"Legend\">\r\np1 = plot(t1, y1);\r\nhold on;\r\ngrid minor;\r\np2 = plot(t2, y2);\r\n\r\nlegend(&#x5B;p1, p2], 'sin(x)', 'cos(x)',...\r\n       'Location','northwest',\r\n       'Orientation','horizontal');\r\n<\/pre>\n<pre class=\"brush: plain; title: Axis; notranslate\" title=\"Axis\">\r\nfig = figure(1);\r\nax  = fig.CurrentAxes;\r\n\r\n% DOESN'T WORK!!\r\nhold(ax,'on');\r\n\r\n% Set gca and use 'current axis' (gca)\r\naxis(ax)\r\nhold on;\r\n<\/pre>\n<p>Round \/ Floor \/ Ceiling<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/floor.html\"><code>floor<\/code><\/a>, Round toward negative infinity<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/ceil.html\"><code>ceil<\/code><\/a>, Round toward positive infinity<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/round.html\"><code>round<\/code><\/a>, Round to nearest decimal or integer<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fix.html\"><code>fix<\/code><\/a>, Round toward zero<\/p>\n<p>Time and Date<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/clock.html\"><code>clock<\/code><\/a>, Current date and time as date vector<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/datetime.html\"><code>datetime<\/code><\/a>, Create array based on current date, or convert from date strings or numbers<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/posixtime.html\"><code>posixtime<\/code><\/a>, Convert MATLAB datetime to POSIX time<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/datestr.html\"><code>datestr<\/code><\/a>, Convert date and time to string format<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/datenum.html\"><code>datenum<\/code><\/a>, Convert date and time to serial date number<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_prog\/compute-elapsed-time.html\">Date and Time Arithmetic<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/datetime-properties.html\">datetime Properties<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt;&gt; c = clock()\r\n    2.0170    0.0050    0.0120    0.0160    0.0290    0.0050\r\n\r\n&gt;&gt; fix(c)\r\n        2017           5          12          16          29           4\r\n\r\n&gt;&gt; t = datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss Z')\r\n   2017_05_12_16_35_19 (as datetime object)\r\n\r\n&gt;&gt; t = datetime('now');\r\n&gt;&gt; datestr(t, 'yyyy_MM_dd_HH_mm_ss')\r\n2017_35_12_16_05_28\r\n\r\n&gt;&gt; t = datetime('now');\r\n&gt;&gt; unix_time = posixtime(t);\r\n&gt;&gt; t = datetime(unix_time, 'ConvertFrom', 'posixtime');\r\n\r\n&gt;&gt; num2str(posixtime(datetime('now')))\r\n1494612053.581\r\n&gt;&gt; num2str(posixtime(datetime('now')) * 1000)\r\n1494611994358\r\n\r\n<\/pre>\n<p>Axis-Ticks<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/xticks.html\"><code>xticks<\/code><\/a>, Set or query x-axis tick values (DOESN&#8217;T WORK!)<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/creating_plots\/change-tick-marks-and-tick-labels-of-graph-1.html\">Specify Axis Tick Values and Labels<\/a><\/p>\n<p>Camera<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/camva.html\"><code>camva<\/code><\/a>, Set or query camera view angle<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/campos.html\"><code>campos<\/code><\/a>, Set or query camera position<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/camzoom.html\"><code>camzoom<\/code><\/a>, Zoom in and out on scene<\/p>\n<p>Lineare Algebra<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/symbolic\/linsolve.html\"><code>linsolve <\/code><\/a>, Solve linear system of equations given in matrix form<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/tril.html\"><code>tril<\/code><\/a>, Lower triangular part of matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/triu.html\"><code>triu<\/code><\/a>, Upper triangular part of matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/diag.html\"><code>diag<\/code><\/a>, Create diagonal matrix or get diagonal elements of matrix<\/p>\n<p>Quaternion<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/aerotbx\/ug\/quatmultiply.html\"><code>quatmultiply<\/code><\/a>, Calculate product of two quaternions<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/aerotbx\/ug\/quatinv.html\"><code>quatinv<\/code><\/a>, Calculate inverse of quaternion<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/robotics\/ref\/quat2rotm.html\"><code>quat2rotm<\/code><\/a>, Convert quaternion to rotation matrix<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/aerotbx\/ug\/quatnormalize.html\"><code>quatnormalize<\/code><\/a>, Normalize quaternion<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/robotics\/ref\/eul2quat.html\"><code>eul2quat<\/code><\/a>, Convert Euler angles to quaternion<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/robotics\/ref\/quat2eul.html\"><code>quat2eul<\/code><\/a>, Convert quaternion to Euler angles<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/robotics\/ref\/quat2tform.html\"><code>quat2tform<\/code><\/a>, Convert quaternion to homogeneous transformation<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/robotics\/ref\/tform2quat.html\"><code>tform2quat<\/code><\/a>, Extract quaternion from homogeneous transformation<\/p>\n<p>Euler<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/aerotbx\/ug\/angle2dcm.html\"><code>angle2dcm<\/code><\/a>, Convert rotation angles to direction cosine matrix<\/p>\n<p>Images \/ Bilder<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/imread.html\"><code>imread<\/code><\/a>, Read image from graphics file<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/imfinfo.html\"><code>imfinfo<\/code><\/a>, Information about graphics file<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/imshow.html\"><code>imshow<\/code><\/a>, Display image<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/image.html\"><code>image<\/code><\/a>, Display image from array<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/imagesc.html\"><code>imagesc<\/code><\/a>, Display image with scaled colors<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/images\/ref\/im2uint8.html\"><code>im2uint8<\/code><\/a>, Convert image to 8-bit unsigned integers<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/rgb2gray.html\"><code>rgb2gray<\/code><\/a>, Converts the truecolor image RGB to the grayscale intensity image I<\/p>\n<p>Radon Transformation<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/images\/ref\/radon.html\"><code>radon<\/code><\/a>, Radon transform<\/p>\n<p>Serial<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/serial.html\"><code>serial<\/code><\/a>, Create serial port object<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/instrfind.html\"><code>instrfind<\/code><\/a>, Read serial port objects from memory to MATLAB workspace<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/serial.fopen.html\"><code>fopen <\/code>(serial)<\/a>, Connect serial port object to device<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/readasync.html\"><code>readasync<\/code><\/a>, Read data asynchronously from device<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_external\/writing-and-reading-data.html\">Serial Write and Read Data<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_external\/events-and-callbacks.html\">Serial Events and Callbacks<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/matlab_external\/timeout.html\">Timeout<\/a>, Waiting time to complete a read or write operation<\/p>\n<p>File<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fopen.html\"><code>fopen<\/code><\/a>, Open file, or obtain information about open files<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fwrite.html\"><code>fwrite<\/code><\/a>, Write data to binary file<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fread.html\"><code>fread<\/code><\/a>, Read data from binary file<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fclose.html\"><code>fclose<\/code><\/a>, Close one or all open files<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/fprintf.html\">fprintf<\/a>, Write data to text file<\/p>\n<p>Regelungstechnik \/ Control System<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/ident\/ref\/step.html\"><code>step<\/code><\/a>, Step response plot of dynamic system; step response data<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/control\/ref\/stepdataoptions.html\"><code>stepDataOptions<\/code><\/a>, Options set for step<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/control\/ref\/tf.html\"><code>tf<\/code><\/a>, Create transfer function model, convert to transfer function model<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/control\/ref\/zpk.html\"><code>zpk<\/code><\/a>, Create zero-pole-gain model; convert to zero-pole-gain model<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/ident\/ref\/impulse.html\"><code>impulse<\/code><\/a>, Impulse response plot of dynamic system; impulse response data<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/control\/ref\/ss.html\"><code>ss<\/code><\/a>, Create state-space model, convert to state-space model<\/p>\n<p>Filter<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/filter.html\"><code>filter<\/code><\/a>, 1-D digital filter: processing the input data ONLY in forward directions<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/signal\/ref\/filtfilt.html\"><code>filtfilt<\/code><\/a>, Zero-phase digital filtering: processing the input data in forward and reverse directions<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/signal\/ref\/designfilt.html\"><code>designfilt<\/code><\/a>, Design digital filters<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/conv.html\"><code>conv<\/code><\/a>, Convolution and polynomial multiplication<\/p>\n<p>ECG \/ EKG<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/wavelet\/ug\/r-wave-detection-in-the-ecg.html\">R Wave Detection in the ECG<\/a><br \/>\n<a href=\"https:\/\/www.mathworks.com\/examples\/signal\/mw\/signal-ex53403527-peak-analysis?s_tid=examples_p1_BOTH\">Peak Analysis<\/a><br \/>\n<a href=\"https:\/\/www.mathworks.com\/examples\/instrument\/community\/22330-example-of-measuring-heart-rate-from-acquired-ecg-signals?s_cid=rlcnt_ME\">Example of Measuring Heart Rate from Acquired ECG Signals<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/fileexchange\/10858-ecg-simulation-using-matlab\">ECG simulation using MATLAB<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/fileexchange\/45840-complete-pan-tompkins-implementation-ecg-qrs-detector\">Complete Pan Tompkins Implementation ECG QRS detector<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ns       = tf('s');\r\nI_Gs    = Ks \/ (T1 * s);\r\nIT1_Gs  = Ks \/ (T1 * s^2 + s);\r\n\r\n&#x5B;  I_y,   I_t] = step(  I_Gs, Tend);\r\n&#x5B;IT1_y, IT1_t] = step(IT1_Gs, Tend);\r\n<\/pre>\n<h3>Properties<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/root-properties.html\">Root Properties<\/a>, Graphics environment and state information<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/figure-properties.html\">Figure Properties<\/a>, Control appearance and behavior of figure window<br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/chartline-properties.html\">Chart Line Properties<\/a> (<code>plot<\/code>)<br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/axes-properties.html\">Axes Properties<\/a><br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/text-properties.html\">Text Properties<\/a><br \/>\n<a href=\"http:\/\/ch.mathworks.com\/help\/matlab\/ref\/legend-properties.html\">Legend Properties<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/ref\/scatterseries-properties.html\">Scatter Series Properties<\/a><\/p>\n<h4>Camera Properties<\/h4>\n<p><a href=\"https:\/\/ch.mathworks.com\/help\/matlab\/visualize\/low-level-camera-properties.html\">Low-Level Camera Properties<\/a><br \/>\n<a href=\"http:\/\/www.thphys.nuim.ie\/CompPhysics\/matlab\/help\/techdoc\/umg\/chview6.html\">Low-Level Camera Properties<\/a><\/p>\n<table>\n<tr>\n<td>CameraViewAngle<\/td>\n<td>Specifies the field of view of the &#8220;lens.&#8221; If you specify a value for CameraViewAngle, MATLAB overrides stretch-to-fill behavior (see the &#8220;Aspect Ratio&#8221; section).<\/td>\n<\/tr>\n<tr>\n<td>CameraViewAngleMode<\/td>\n<td>In automatic mode, MATLAB adjusts the view angle to the smallest angle that captures the entire scene. In manual mode, you specify the angle.<br \/>\nSetting CameraViewAngleMode to manual overrides stretch-to-fill behavior.<\/td>\n<\/tr>\n<\/table>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n% disable the stretch-to-fill behavior\r\n\r\nset(gca,'CameraViewAngleMode','manual');\r\nset(gca,'CameraViewAngle',10);\r\nset(gca,'DataAspectRatio',&#x5B;1 1 1]);\r\n\r\ndaspect(&#x5B;1 1 1]);\r\n\r\n%         X      Y      Z\r\nwin = &#x5B; -1, 1, -1, 1, -1, 1];\r\naxis equal;\r\naxis(win);\r\n\r\n=== OR ===\r\n\r\ncamzoom(1);\r\n\r\n<\/pre>\n<p><code>camzoom<\/code> sets the axes <code>CameraViewAngle<\/code> property, which in turn causes the <code>CameraViewAngleMode<\/code> property to be set to <code>manual<\/code>. Note that setting the <code>CameraViewAngle<\/code> property disables the MATLAB <code>stretch-to-fill<\/code> feature (stretching of the axes to fit the window). This may result in a change to the aspect ratio of your graph. See the <code>axes<\/code> function for more information on this behavior.<\/p>\n<h3>MATLAB Game Programming<\/h3>\n<p><a href=\"http:\/\/www.matlabtips.com\/gaming-in-matlab\/\">Gaming in Matlab<\/a><br \/>\n<a href=\"http:\/\/ch.mathworks.com\/matlabcentral\/fileexchange\/34513-matlabtetris\">MATLABTETRIS<\/a><\/p>\n<h3>Call by value vs. Call by reference<\/h3>\n<p><a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/answers\/96960-does-matlab-pass-parameters-using-call-by-value-or-call-by-reference\">Does MATLAB pass parameters using &#8220;call by value&#8221; or &#8220;call by reference&#8221;?<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/answers\/152-can-matlab-pass-by-reference\">Can MATLAB pass by reference?<\/a><br \/>\n<a href=\"https:\/\/ch.mathworks.com\/matlabcentral\/answers\/49390-pass-variable-by-reference-to-function\">Pass variable by reference to function<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Matlab-Schnelleinf \u0308uhrung, PDF, 3 Seiten Formatting Number format, Set Command Window output display format &gt;&gt; a = 1\/3; &gt;&gt; b = 0.001; &gt;&gt; format short a = 0.3333 b = 1.0000e-03 &gt;&gt; format shortE a = 3.3333e-01 b = 1.0000e-03 &gt;&gt; format shortG a = 0.33333 b = 0.001 &gt;&gt; format shortEng a = 333.3333e-003 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5320","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/5320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5320"}],"version-history":[{"count":95,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/5320\/revisions"}],"predecessor-version":[{"id":8788,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/5320\/revisions\/8788"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}