How to Create MAT file in MATLAB Complete Details

Today, I am writing this tutorial for creating and saving M-file in MATLAB. While learning MATLAB, you should know “How to create MAT file in MATLAB”.

Why do you need a MAT-file?

If you are writing the program for solving technical computing or running Simulink model, you need to save the program as M-file in MATLAB.

What is an extension of MATLAB file?

In MATLAB, the new M-file will be saved with an extension of “m”. And MATLAB Simulink model will be saved with an extension of “mdl” or “slx”

Note: M-file is a short abbreviation of MATLAB-file. It is also called as MAT-file. Sometimes, M-file is called as the “Script file”.

How to Create MAT file in MATLAB?

Here are the following steps, you should follow for creating a new file.

1. Firstly, open the MATLAB software. And click on the New Script topmost option from the Home of the MATLAB window. This new script is used for creating a new File in MATLAB. [as shown in below image]


2. After selecting the new script, you will see the Editor option. You will see the Untitled new M-File for writing the new MATLAB program.


3. Before writing any program or any technical computing in Command Window, you should Save the file in your desired folder.


Note: Extension of the new MATLAB file should be “mat” or ” m “ file.

MAT File Example:

For Example, Here I am saving the M-File with the naming DipsLab.m.


Sample MAT File Program (Example)

Write a MATLAB program to solve the mathematical calculation, for example, the addition of two numbers (calculate the value of ‘a’).

Solution:

Let consider,

>> x=2; y=4;

>>  a=x+y

a     =

          6

Here,

I am clicking on the Save Workspace option in the MATLAB window.  And saving this file with the name of the “Addition.mat” in the new folder.


Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *