Introduction to MATLAB – The name MATLAB stands for MATrix LABoratory. MATLAB was originally written to provide easy access to the matrix software developed in the LINPACK (a software package for linear systems) and EISPACK (a software package for native systems) projects.
MATLAB is a powerful language for technical calculations. It integrates computation, visualization and programming environment. In addition, MATLAB is a modern programming environment: It has complex data structures, includes integrated editing and debugging tools, and supports objectoriented programming. These factors make MATLAB an excellent tool for education and research.
For solving technical problems, MATLAB offers many advantages over traditional computer languages (e.g., C, FORTRAN). MATLAB is an interactive system whose master data element is an array, requiring no dimensionality. The software has been commercially available since 1984 and is now considered a standard tool in most universities and industries around the world.
It has powerful builtin procedures that allow it to perform various calculations. It also has easytouse graphical controls that allow for immediate visualization of the results. Specific applications are assembled into packages called toolkits. There are instruments for signal processing, symbolic calculations, control theory, simulation, optimization and several other areas of applied science and engineering.
Start MATLAB
When you start MATLAB, a special window called MATLAB Desktop appears. The desktop is a window that contains other windows. Basic tools available on or accessible from the desktop :
– order screen
– Command history
– working space
– Current catalogue
– browser support
– ignition switch
MATLAB workspace graphical user interface (GUI)
When you start MATLAB for the first time, the screen looks like Figure 1.1. This figure also shows the default configuration of the MATLAB desktop. You can customize the presentation of the tools and documents to suit your needs.
We are now interested in simple calculations. We assume that you know your computer working with MATLAB well enough.
You are now on your computer’s MATLAB desktop, which contains a tooltip (>>) in the command window. There are generally two types of messages:
>> for the full version
EDU> for the training version
Pay attention: For ease of scoring, we will use this index, >>, as the default index character, even though our version of MATLAB is intended for educational purposes.
Also check : Wireshark Tutorial for beginners 2021  Network Packet Analyzer
Using MATLAB as a calculator
As an example of a simple interactive calculation, simply enter the expression you want to estimate. Let’s start at the beginning. For example, suppose you want to calculate an expression 1 + 2 × 3. Enter it in the command line (>>) as follows,
>> 1+2*3
Answer = 7
Note that if you do not specify an output variable, MATLAB uses the default year variable, abbreviated as answer, to store the results of the current calculation. Note that the variable years are created (or overwritten if they already existed). To avoid this, you can assign a value to a variable or the name of an output argument. For example
>> x = 1+2*3
x = 7
leads to the fact that x has the value 1 + 2 × 3 = 7. The name of this variable can still be used to refer to the results of previous calculations. A calculation with the factor 4 therefore gives
>> 4*x
Answer = 28.0000
See the following table for a partial list of arithmetic operators before closing this minimum session.
Basic arithmetic operators
MATLAB output
To end a MATLAB session, type Exit in the command window or choose File > Exit MATLAB from the main desktop menu.
Beginning of activity
After learning a minimal MATLAB session, we will now learn how to perform a few more operations.
Creation of MATLAB variables
MATLAB variables are created using the assignment operator. Syntax of variable assignment
Variable name = value (or expression)
For example, for example..,
>> x = expression
where the expression is a combination of numeric values, mathematical operators, variables and function calls. In other words, the expression can :
Manual
– integrated features
– user features
Replace variable
Once a variable is created, it can be reassigned. If you do not want to see intermediate results, you can also suppress the digital output by placing a semicolon (;) at the end of the line. The order of the commands then looks like this:
>> t = 5 ;
>> t = t+1
t = 6
Error messages
If we enter a wrong expression, MATLAB gives an error message. For example, we forgot the multiplication sign, *, in the following expression
>> x = 10 ;
>> 5x
? ?? 5x

Wrong: An unexpected expression of MATLAB.
Corrections
To make corrections, you can of course retype expressions. But if the expression is long, you will make more mistakes by typing a second time. A previously selected command can be called up by pressing the arrow key ↑. When a command is displayed on the command line, it can be modified and executed as desired.
Operational hierarchy or seniority management
Remember the previous arithmetic operation, but now include the parentheses. For example, 1 + 2 × 3 becomes (1 + 2) × 3.
>> (1+2)*3
Answer = 9
and, based on the previous example
>> 1+2*3
Answer = 7
By adding parentheses, the two expressions give different results: 9 и 7
The order in which MATLAB performs arithmetic operations is exactly the same as the order taught in school algebra classes. First we explain, then we multiply and divide, and finally we add and subtract. However, the default order of arithmetic operations can be changed by inserting parentheses. For example, the result 1+2×3 is very different from the same expression with parentheses (1+2)×3. Results 7 and 9 respectively. Brackets can always be used to override precedence, and their use is recommended in certain complex expressions to avoid ambiguity.
In order to make the evaluation of expressions unambiguous, MATLAB has established a set of rules. The procedure for evaluating arithmetic operations is given in the following table.
Hierarchy of arithmetic operations
MATLAB calculation operators follow the same priority rules as most computer programs. In the case of equivalent operators, the evaluation shall be carried out from left to right. Now let’s take another example:
In MATLAB the
>> 1/(2+3^2)+4/5*6/7
Answer = 0.7766
or if there are no hooks,
>> 1/2+3^2+4/5*6/7
Answer = 10.1857
So we get two different results. We would therefore like to stress the importance of the priority rule to avoid any ambiguity.
Controlling the appearance of floating point numbers
By default, MATLAB displays only 4 decimal places as the result of calculations, for example. B. 163.6667, as shown in the examples above. However, MATLAB performs numerical calculations with double precision, i.e. with 15 digits. The command format controls the display of calculation results. Here are some examples of different formats and the results obtained.
>> Short format
>> x=163.6667
If we want to see the 15 digits, we use the long order format.
>> Long format
>> x= 1.636667e+002
To return to the default format, enter the short format or just the format.
Several other formats are available. See the MATLAB documentation or Help format for more information.
Note – So far, we have allowed MATLAB to repeat everything we type at the (>>) prompt. Sometimes it doesn’t really make sense, especially if it’s a long page. To prevent MATLAB from reflecting the word you type, simply type a semicolon (;) at the end of the command. For example, for example..,
>> x=163.6667 ;
and then ask for the value of X when you enter it,
>> x
x = 163.6667
Workspace management
The content of the work area is saved between the execution of each job. Thus, the results of one problem may affect the other. To avoid this possibility, it is useful to give clear orders at the beginning of each independent recalculation.
>> pure
The clear or clear all command removes all variables from the workspace. This frees up the system memory. To display a list of variables currently in memory, enter the following type
>> who
At the same time, more detailed information is given, including the size, space allocation, and class of the variable.
Followup to a working session
Use the log command to record everything that is done during a MATLAB session.
>> Newspaper
or name the file you created,
>> Log file name
where FileName can be any name.
A function log is useful when you want to record an entire MATLAB session. You save all input and output data as they appear in the MATLAB window. To stop recording, enter the log. If you want to start recording again, enter the log. The generated file is a simple text file. It can be opened and edited with an editor or word processor to remove unnecessary items or add comments. You can use the function type to display the calendar file or to modify or print it in a word processor. This command is z. For example, useful when preparing homework assignments or a laboratory presentation.
Enter more than one instruction per line
Several instructions can be entered per line. Use commas (,) or semicolons (;) to enter more than one entry at a time. Commas (,) allow multiple operators per line without suppressing the output.
>> a=7; b=cos(a), c=cosh(a)
b = 0.6570
c = 548.3170
Miscellaneous controls
Here are some more useful commands:
– To clear the command window, type clc
– To interrupt a MATLAB calculation, type ctrlc
– To continue the line, enter.
Getting help
To view the online documentation, choose MATLAB Help from the Help menu or MATLAB Help directly from the command window. The preferred method is to use the auxiliary browser. The Auxiliary Browser can be launched by selecting the ? icon on the desktop toolbar. On the other hand, information about each order is available by entering
>> Help Team
Another way to get help is to use the lookfort command. The lookfor command is different from the help command. The help command looks for an exact match of the function name, while the search command looks for a brief summary of the information in each function to find a match. For example, suppose we are looking for a function that takes an inverse matrix. Since MATLAB has no function with an inverted name, the inverted help command does nothing. On the other hand, the reverse command produces detailed information that includes the inv. of interest function.
>> look the other way
Post Views : 1
Related Tags:
introduction to matlab for economists, matlab introduction course, quadrature routine matlab, matlab quadrature integration, matlab stanford pdf, getting started with matlab rudra pratap pdf, matlab tutorial for image processing, matlab programming basics, desktop of matlab, how many windows are there in matlab, matlab array i, matlab desktop tools, introduction to matlab slideshare, matlab course ware, introduction to simulink, matlab advantages, introduction to matlab coursera, matlab exercises and solutions pdf, matlab tutorial youtube, matlab programming book, matlab program example, simple matlab program to add two numbers, mit matlab lecture notes, mit matlab course, matlab course for engineers, mit matlab portal, mit opencourseware answers, matlab lecture notes ppt, introduction to matlab lab report, matlab lecture notes open university, matlab introduction and applications pdf, explain matlab help and demo, getting started with matlab 7, user guide of matlab, introduction to matlab tutorial point, introduction to matlab python, matlab online courses nptel, matlab training fees, learn matlab step by step, matlab programming pdf, matlab coursera, matlab online course for mechanical engineers, matlab tutorial pdf, matlab documentation, introduction to matlab textbook, introduction to matlab – ppt, best matlab tutorial, matlab basics, download matlab