Categories

# MATLAB Toolbox

In this article, we will study about toolboxes in MATLAB. The toolboxes in MTALB are a collection of numerous functions that are built on MATLAB’s computing environment.

Here are a few toolboxes in MATLAB:

1. ‘Curve Fitting’
2. ‘Regression learner’
3. ‘Image processing’

These toolboxes can be accessed using the ‘APPS’ icon in MATLAB ribbon. Let us now understand the use of a couple of toolboxes in MATLAB:

## Curve Fitting Toolbox

• Curve fitting toolbox is used to fit the surfaces and curves to input data while using interpolation, regression, and smoothing.
• This Toolbox provides us with functions and an application to fit curves to our data.
• This toolbox is very helpful in data analytics as it helps in performing EDA (exploratory data analysis), data processing and removing outliers

Let us now understand the use of the Curve fitting toolbox using an example.

## Example:

In this example, we will use 3 metrics ‘x’, ‘y’, ‘z’ and will fit a curve in them using the Curve fitting toolbox. We will follow the following steps:

1. Create the 3 matrices using rand function
2. Set the ‘X Data’, ‘Y Data’, ‘Z Data’ in Curve fitting tool to our inputs, ‘x’, ‘y’, ‘z’ respectively

Code: (to be executed in Command Window)

``````x = rand (5)
y = rand (5)
z = rand (5)[Creating the 3 input matrices]``````

Once we execute the above code in ‘Command Window’, we will get the 3 variables created in our ‘WORKSPACE’.

## Steps to Use Curve Fitting toolbox

Step 1: Click on APPS icon

Step 2: Select ‘Curve Fitting Tool’

Step 3: A pop-up window will open like below:

Step 4: Now set the ‘X Data’, ‘Y Data’, ‘Z Data’ in this pop-up window to our inputs, ‘x’, ‘y’, ‘z’ respectively. We can immediately see that a curve will be created by Curve Fitting Toolbox. The equation for this curve can be seen in the Result section. We can use a custom equation using the dropdown on the top of the curve.

## Output:

As we can see in the output, we have obtained a curve, fitting the input variables ‘x’, ‘y’, and ‘z’, which is the same as expected by us.

Next, let us learn how Regression Learner Toolbox works in MATLAB

## Regression Learner Toolbox

• Regression Learner toolbox is used to perform regression
• It is used to train a model automatically
• It can also be used to compare different options amongst linear regression, support vector machines, regression trees & visualize the results

Let us now understand the use of the Regression Learner toolbox using an example.

## Example:

In this example, we will use an inbuilt dataset provided by MATLAB, ‘carbig’. We will upload this dataset to the ‘Regression Learner Toolbox’ and will explore the possible options. We will follow the following steps:

• Load the inbuilt dataset ‘carbig’
• Create a table using this dataset to load it into ‘Regression Learner Toolbox’

## Code: (to be executed in Command Window)

`load carbig`[Loading the ‘carbig’ dataset into the Workspace]

``````newTable = table (Cylinders, Acceleration, Displacement,...
Model_Year, Horsepower, Weight, Origin);[Creating the table using the dataset to make it compatible with Regression Learner Toolbox]``````

Once we execute the above code in ‘Command Window’, we will get the ‘newTable’ created in our ‘WORKSPACE’.

## Steps to Use Regression Learner Toolbox

Step 1: Click on APPS icon

Step 2: Select ‘Regression Learner Toolbox’

Step 3: A pop-up window will open like below:

Step 4: Click on New Session in the left which will open a new window prompt

Step 5: From the ‘Data Set Variable’ dropdown, select the ‘newTable’ table created by us

Step 6: This will load all the predictor variables under the section ‘Predictors’

Step 7: Now we can select the predictor variables as per our requirement

Step 8: Click on ‘Start Session’, to start analyzing the data

We can immediately see a response plot created by Regression Learner Toolbox. Now as per our requirement, we can train this data and get a response plot, residual plot, min MSE plot using the options available.

## Output:

Let us now understand the use of the Image processing toolbox using an example.

## Image Processing Toolbox

below we will learn about image processing toolbox:

## Example:

In this example, we will use one of the inbuilt images provided by MATLAB, ‘moon.tiff. We will upload this dataset to ‘Image processing Toolbox’ and will explore the possible options.

## Code: (to be executed in Command Window)

``moonImage = imread ('moon.tif')``

`imtool (moonImage)`

[Using ‘imtool’ function to start the Image processing toolbox. Alternatively, we can also select it from the APP section]

Once we execute the above code in ‘Command Window’, we will get the ‘moonImage’ in our ‘WORKSPACE’.

## Options Provided by Image Processing Toolbox

• Pixel Information
• Distance between the 2 pixels