What is MATLAB ?

EA & HAM Club, NIT Warangal
7 min readAug 24, 2021

--

how to use matlab guide by ea and ham club nitw

If you are an engineering student we bet you must have heard about MATLAB. Do you know what its used for? and the amazing things you can do with it?. You will be able to make your first file in MATLAB and know everything you need to know about the MATLAB software at the end of this detailed article, complied by EA and HAM Club, NIT Warangal. We have also included a few interesting examples of MATLAB projects at the end of the article. So make sure you check it out

Here is what we are going to go through

  1. What is MATLAB?
  2. Why should you even use Matlab?
  3. Installation Guide
  4. Creating your first program
  5. Building and simulating a simple Simulink model
  6. Few interesting examples
  7. More Resources

1. What is MATLAB?

Matlab is a programming language and environment helps to compute, design, simulate, visualize and analyze systems.

We don’t believe in giving you boring definitions, here’s what you need to actually know

  • Matlab = Matrix Laboratory
  • Matlab is a high-level language and interactive environment for numerical computation, visualization and programming.
  • and products that transform our world.
  • It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation.

2. Why should you even use Matlab?

Why should you even read this article? Well , because it solves a lot of problems for you. MATLAB is a one step solution to your problems if

  • your idea or design process relies on Math computation
  • You want to Simulate the process for analyzing the result
  • Do you want to design a mathematical model

Here is what you can do with this epic software

  • Statistics and machine learning(ML)
  • Signal Processing
  • Image processing
  • Electric vehicles designing
  • Aerospace
  • Control systems
  • Deep learning
  • Text analysis
  • Audio toolbox

3. How to install MATLAB?

Here’s a free PDF for the instructions on how to install MATLAB. You can skip this step if you have already installed MATLAB

4. Creating your first program

Let’s now create our very first program on the MATLAB

Matlab 101

  1. After you have successfully downloaded and installed MATLAB you may go ahead and open it up to see what’s inside.
  2. After a few seconds (maybe longer if you are opening it up for the first time) you will be able to view the whole MATLAB console window.
  3. This window, if you noticed is divided into several different segments as follows: -
How to use the matlab software? how to create your first file in matlab? matlab
  • The Current Folder (Far Left) browser enables you to interactively manage files and folders in MATLAB. Use the Current Folder browser to view, create, open, move, and rename files and folders in the current folder.
  • The Command Window enables you to enter individual statements at the command line and view the generated results.
  • The workspace contains variables that you create or import into MATLAB from data files or other programs. You can view and edit the contents of the workspace in the Workspace browser or in the Command Window.
  • You may also consider installing additional toolboxes using the Add-Ons button on the Home toolbar.

Performing a simple calculation using MATLAB

  • The image below shows some lines written on the command window, notice that the variables have their values displayed on the workspace too.
simple calculations in matlab
  • You may wish to clear the workspace or the command window by typing in clear and clc commands on the window respectively.

File management in MATLAB

  • To write and store new functions you would need to use the new file button on the top right header of the corner
File management in MATLAB presented by EA and HAM club at NIT Warangal
  • Click on the New script button and your MATLAB console will look something like this:
writing your first file in MATLAB. comprehensive guide by EA and HAM club NIT Warangal
  • After typing up a function you would need to save it. The steps below would guide you.
MATLAB 101 by EA and HAM club NITW
  • A dialog box would appear prompting you to save the file you have created. Save it appropriately and click OK.
  • Once you are done the current folder will be automatically updated to reflect your recent actions.
simu link

Using function files in MATLAB

  • You can call the function from the command line, using the same syntax rules that apply to functions installed with MATLAB. For instances, calculate the factorial of 5.
  • You would need to type the following commands in the command window
using function files in matlab | EA and Ham Club NIT Warangal

5. Building and simulating a simple Simulink model

Simulink is a block diagram environment for multi domain simulation and Model-Based Design. It supports system-level design, simulation, automatic code generation, and continuous test and verification of embedded systems.

It is integrated with MATLAB, enabling you to incorporate MATLAB algorithms into models and export simulation results to MATLAB for further analysis.

Creating your first application in Simulink

1. Type Simulink in command window and press enter

simulink

2. It takes a while to open the Simulink start page. Explore the Simulink start page and see how to use several of the basic blocks and modelling components

matlab simulink model | how to use matlab | ea and ham nitw

3. Select the Blank model to start doing your problem. You can see a window like this pops up.

matlab simulink model

4. Save your file in the directory you want to save.

saving simulink
simulink model
  • Observe that your Simulink models get saved as a .slx file.

5. Beside the save button, you can find the Library browser. Click on it.

  • The Library model is used for building simulation models.
matlab simulink how to use matlab ea and ham nitw

A Simulink model is a block diagram. Model elements are added by selecting the appropriate elements from the Library Browser and dragging them into the Model window. Alternatively, you can copy the model elements and paste them into the model window.

6. Let us create a simple model of amplifying sine waves. Search for sources in Library browser and you can find sine wave in the sources

matlab simulink ea and ham
  • If you right click on it, you can see option “Add block to model Model_name” ,click on it. Or just drag and drop the sine wave into the modal window.

7. If you double click on the block in the model window, the Block parameter window gets open. You can adjust the parameters of the block here.

matlab simulink nitw
  • Let us stick to the default Amplitude of 1 for sine waves in this example.

8. Similarly search for gain and scope in the Library browser and add them to the model window.

9. Change the gain value to 5 in its Block paraments window (double click on gain window)

10. Connect them as shown in figure.

matlab simulink nitw

11. Run the model and double click on the scope.

matlab simulink nitw

You can observe that a sine wave of amplitude 1 is amplified with gain 5.

6. Few Interesting examples

Data Scraping from Website (Data Mining)

Matlab is a very powerful computer software/programming language that is able to automate many tasks. As an example, given a scenario where the Marketing Department would want to populate a set of data from third party data provider which is a web-facing interface, Matlab can be used to automatically browse millions of websites, and store the information using HTML/text format.

But don’t just stop there, using patterns, Matlab can also be used to extract the data needed from the documents and analyzed using statistical tools to gain marketing insights with respect to the patterns being set earlier.

Home Automation

Your computer can be a host device to command actions to achieve home automation. With the capability of Matlab to communicate with prototyping hardware such as Arduino, you can set timers for certain actions such as lighting, turning on the air conditioners, controlling the water pumps, watering plants, visual monitoring, facial recognition door lock and so on.

Hope you guys found this Article helpful. Share it with your friends to encourage them in learning the essential MATLAB. Here are a few more free resources on MATLAB

7. More resources

  1. https://drive.google.com/drive/folders/10Ne8b2ELCky7DVO3Axvfx-KNHIi3KcKw?usp=sharing
  2. https://www.coursera.org/learn/matlab
  3. https://www.analyticsvidhya.com/resources-learn-matlab-programming/
  4. https://www.tutorialspoint.com/matlab/index.htm
  5. https://matlabacademy.mathworks.com/details/simulink-onramp/simulink?s_tid=course_slor_start1

--

--

EA & HAM Club, NIT Warangal
EA & HAM Club, NIT Warangal

Written by EA & HAM Club, NIT Warangal

A group of techies who love to explore new domains of technology which aims to attain and impart the knowledge.^BlogsCANbeAgreatWAYtoexchangeKNOWledge^