MATLAB For Beginners
MATLAB (matrix laboratory) is a high-level script programming language and interactive environment for numerical computation, visualization and programming. MATLAB is developed by the MathWorks company. It started out as a matrix programming language but now It can run both under interactive sessions and as a batch job.
Engineers and Scientists use MATLAB because it combines a desktop environment tuned for iterative analysis and design processes with a programming language that expresses matrix and array mathematics directly. Today we use MATLAB to solve complex mathematical problems using Data Analytics, Wireless Communications, Deep Learning, Computer Vision, Signal Processing, Robotics, and Control System toolboxes. This tutorial is to help students understand the basics and few advanced functionality of MATLAB. After completing this tutorial you will gain basic understanding of the MATLAB program in order to advance to the next level. Good luck! Arrays and Matrices
Array Creation: To create an array with four elements in a single row, separate the elements with either a comma (,) or a space.
Below are some more examples.
Now we will solve some textbook questions.
|
\(\color{red}{a = (5- {19/ 7}+2.5^3)^2}\)
Script: clc; a = (5-19/7+2.5^3)^2; fprintf('a = %0.4f \n', a ); -----ans------------ a = 320.7937 --------------------- \(\color{red}{b = \sqrt[3]{8+ {\frac {80}{2.6}}} + e^{3.5}}\) Script: clc; b = nthroot(8+(80/2.6),3)+ exp(3.5); fprintf('a = %0.4f \n', b); -----ans------------ b = 36.5000 --------------------- |
\(\color{red}{c = 7*3.1+ \frac {\sqrt {120}}{ 5} -15^ {5/3}}\)
Script: clc; c= 7*3.1+(sqrt(120)/5)-15^(5/3); disp (b ) -------ans---------- c = -67.3421 --------------------- \(\color{red}{d = \frac{\sin{0.2 /\pi}} {\cos{\pi/6}}+\tan(72°)}\) Script: clc; d = (sin(0.2*pi)/(cos(pi/6)))+tand(72); disp (a) -----ans------------ 3.7564 --------------------- |
Advanced MatLab applications Latex codes for website Matlab script: syms x phi latex(x^2 + 1/x) latex(sin(pi*x) + phi) ----ans-------------------- ans = '\frac{1}{x}+x^2' ans = '\varphi +\sin\left(\pi \,x\right)' ----------------------------- Use "MatJax" or similar JavaScript platform to generate any math equations. Example: Using the above Matlab generated Latex code, you can generate the following expressions in your webpage. => \pi +\sin\left(\pi \,x\right) \(\color{red}{prints: }\) \(\pi +\sin\left(\pi \,x\right)\) => \varphi +\sin\left(\pi \,x\right) \(\color{red}{prints: }\) \(\varphi +\sin\left(\pi \,x\right)\) This is exactly how the math equations are generated in this website. |