# Introduction to Data, Signal, and Image Analysis with MATLAB Quiz Answers

## Get Introduction to Data, Signal, and Image Analysis with MATLAB Quiz Answers

Welcome to Introduction to Data, Signal, and Image Analysis with MATLAB!

MATLAB is an extremely versatile programming language for data, signal, and image analysis tasks. This course provides an introduction on how to use MATLAB for data, signal, and image analysis.

After completing the course, learners will understand how machine learning methods can be used in MATLAB for data classification and prediction; how to perform data visualization, including data visualization for high dimensional datasets; how to perform image processing and analysis methods, including image filtering and image segmentation; and how to perform common signal analysis tasks, including filter design and frequency analysis.

**Introduction to Data, Signal, and Image Analysis with MATLAB Week 01 Quiz Answers**

** practice Quiz : Detecting Outliers**

Q1. A common data analysis task is outlier detection. One example would be if we are managing security on internet networks and would like to detect anomalies in the volume of data sent over our network nodes. Higher than usual traffic should be detected and flagged so that it can be investigated to ensure it is not being caused by malicious activities.

The standard deviation distance function created in the previous assignment can be used for such outlier detection tasks. It is common to label data as outlier if it lies more than a specified number of standard deviations from the mean, i.e., if the standard deviation distance to the mean is larger than a specified number. Typically this is chosen to be 3 or larger. Smaller numbers represent more typical deviations from the mean. Afterall, 1 standard deviation is intended to represent the most typical deviation from the mean, and therefore should not be considered an outlier.

In the attached ‘.mat’ file, you will find data vector **nodetraffic**, which represents recordings of the number of data packets per second travelling through a node.

**What is the mean of the dataset, rounded to the nearest integer?**nodetrafficMAT File

**9829**- 14009
- 12657

Q2. What is the standard deviation of the dataset, rounded to the nearest integer?

- 12657
**14009**- 9829

Q3. If we decide to classify the traffic for a node as suspicious if the traffic through the node has a standard deviation distance (see previous matlab grader problem on “standard deviation distance”) to the mean that is larger than 6, how many instances in **nodetraffic **are suspicious and warrant further investigation?

**Quiz : PCA**

Q1. In the attached ‘.mat’ file you will find a data matrix ‘dataset’, containing 491 samples of a 10 feature dataset. This 10-dimensional dataset contains a “secret” 2D message, that you will find difficult, if not impossible, to decode with standard scatter plots of combinations of different dimensions. The 2D subspace where the message is legible corresponds to the two directions of greatest variance in the dataset. Thus, principal components analysis can be used to decode the message.

- Use the ‘pca’ function to perform principal components analysis.
- The PCA coordinates for the datapoints, D_pca, are contained in the second output of ‘pca’. This is the representation of the data in the PCA linear vector space, where the first dimension is the direction of greatest variance, the 2nd dimension is the direction orthogonal to the first that has the greatest variance, and so on.

**What is the maximum value of the data in the first dimension of the PCA linear vector space, rounded to the nearest integer? **DimensionReductionMAT File

- 120
- 363
- 12

Q2. What is the maximum value of the data in the second dimension of the PCA linear vector space, rounded to the nearest integer?

- 12
- 363
- 120

Q3. Scatter plot the coordinates of the samples in the PCA linear vector space in the first two PCA dimensions (the PCA coordinates for the datapoints are contained in the second output of ‘pca’). This represents the data in a 2-D reduced space of the 10-D dataset. To ensure it is displayed in the proper aspect ratio, use:

`axis equal;`

**Quiz : Predicting Fuel Efficiency Using Regression Trees**

Q1. Load the ‘carbig’ dataset into MATLAB. Curate the data into a clean training and testing set using the following code:

```
load carbig
D = [Acceleration, Cylinders, Displacement, Horsepower, Model_Year, Weight];
y = MPG;
msk = ~ismissing(y);
D = D(msk,:);
y = y(msk);
D_train = D(1:2:end,:);
y_train = y(1:2:end);
D_test = D(2:2:end,:);
y_test = y(2:2:end);
rng(0);
```

Fit a regression tree to the training dataset (D_train, y_train) using the automatic hyperparameter optimization option.

**What is the name of the function we use to train a regression tree?**

Q2. Use the model with the predict function to estimate fuel efficiency for cars in the testing dataset (D_test).

Compare the estimation with the true values (y_test). **What’s the mean squared difference between the two, accurate to two decimal places? **You can use the EstimationErrorPlot function we made to find this.

**Quiz : Predicting Fuel Efficiency Using Gaussian Process Regression**

Q1. Load the ‘carbig’ dataset into MATLAB. Curate the data into a clean training and testing set using the following code:

```
load carbig
D = [Acceleration, Cylinders, Displacement, Horsepower, Model_Year, Weight];
y = MPG;
msk = ~ismissing(y);
D = D(msk,:);
y = y(msk);
D_train = D(1:2:end,:);
y_train = y(1:2:end);
D_test = D(2:2:end,:);
y_test = y(2:2:end);
rng(0);
```

Fit a Gaussian Process regression model to the training dataset (D_train, y_train). Use default parameters, with the exception of using the automatic hyperparameter optimization option. and the option:`1'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName','expected-improvement-plus')`

which ensures the results are repeatable.

**What is the name of the function we use to fit a Gaussian Process regression model?**

Q2. Use the model with the predict function to estimate fuel efficiency for cars in the testing dataset (D_test).

Compare the estimation with the true values (y_test). **What’s the mean squared difference between the two, accurate to two decimal places? **You can use the EstimationErrorPlot function we made to find this.

Q3. Which regression method performs better on this task?

- Regression trees
- Gaussian Process regression

**Introduction to Data, Signal, and Image Analysis with MATLAB Week 02 Quiz Answers**

**Quiz : Spectrum plotting**

Q1. After loading the attached ‘.mat’ file, you will have a [220500 x 1] sound signal vector ‘crickets’ with sampling frequency ‘Fs’. When played using soundsc, it sounds quite a bit like crickets at night. But this signal is encoded with a special secret message in its magnitude spectrum.

Implement the MagnitudeSpectrumPlot function. If you have implemented myfft and MagnitudeSpectrumPlot correctly, when viewing the MagnitudeSpectrum plot of the Fourier Transform with the third input argument col=’*’, letters are clearly revealed. What are they?cricketsMAT File

**Quiz : Filter Quality Analysis**

Q1. In the lecture, we demonstrated how our myfft function can be used to analyze frequency content of a signal. If we provide a filter, instead of a signal, to our myfft function, it be used to determine the frequency response of the filter, where the magnitude spectrum plot of the myfft result shows how the filter amplifies or suppresses the frequency content of the signal that it filters.

Let’s use our myfft and MagnitudeSpectrumPlot functions to observe the frequency response characteristics of finite impulse response (FIR) band-pass filters created using the fir1 function as presented in the previous section. Recall that FIR filters are not ideal filters, which means they do not entirely suppress frequencies outside of the passband nor perfectly preserve frequencies in the passband. But, the advantage over ideal filters is that they are practical to implement for real world systems.

Using the code below, we create three band-pass FIR filters that all have the same pass-band. The difference is the window size. The first uses a window size of 10, the next 100, and the last 1000.

```
Fs = 1000;
freq_range = [100,200];
filt10 = fir1(10,freq_range/(Fs/2));
filt100 = fir1(100,freq_range/(Fs/2));
filt1000 = fir1(1000,freq_range/(Fs/2));
```

1. Use your myfft function for each filter, treating the filters identically to signals.

2. Use your MagnitudeSpectrumPlot function to display the magnitude spectrum of each result.

You should observe that increasing window size should improve filter characteristics, making the FIR filter have closer and closer characteristics to an ideal passband of 100-200 Hz. Choosing a window size is always a balancing act that depends on application specific requirements. Larger windows improve filter quality, but require more time and complexity in the system implementing the filter.

**For the filter with a window size of **__10__** (filt10), what is the magnitude of the filter response for the frequency closest to 90 Hz (which is outside the pass-band and thus ideally should be 0)?**

Hint: you can find the index to the frequency closest to 90 Hz by doing:

`[~,i] = min(abs(f-90));`

where f is the frequency vector output from myfft. The magnitude of the frequency response is the magnitude of the Fourier Transform of the filter at that frequency.

Q2. For the filter with a window size of ** 100**, what is the magnitude of the filter response for the frequency closest to 90 Hz (which is outside the pass-band)?

Q3. For the filter with a window size of ** 1000**, what is the magnitude of the filter response for the frequency closest to 90 Hz (which is outside the pass-band)?

**Introduction to Data, Signal, and Image Analysis with MATLAB Week 03 Quiz Answers**

**Quiz : Color Images**

Q1. A color image is formed by creating a 3-channel image matrix, where the 3 channels represent the red, green, and blue intensities for each pixel. In the attached ‘.mat’ file, you will find three single channel 256×256 image matrices R, G, and B.

Use R, G, and B to construct a 256x256x3 color image matix with R forming the first channel, G the second, and B the third. Display the result using the ‘imagesc’ function. **What is the secret message displayed in the resulting color image?**RGBMAT File

**Quiz : Motion**

Q1. Filtering can be used to simulate camera motion occuring when the picture is being taken. The ‘fspecial’ function can be used to generate a horizontal ‘motion’ filter that can be convolved with an image using the ‘conv2’ function.

Use the fspecial function to generate a horizontal motion filter with default parameters.

Apply the filter to the ‘cameraman.tif’ image, and display the results. Use the ‘same’ argument for ‘conv2’ so that the output dimensions match the original image.

**What is the average pixel intensity value of the resulting image (accurate to two decimal places) ?**

**Quiz : Convex Hull**

Q1. Often we want to remove noise in a segmentation as discussed in the lecture. We explored filtering and connected components analysis as tools that can help with this process. Another tool is called the “convex hull” algorithm. It is often useful to “fill in the holes” that exist in the foreground of a mask.

This method finds a filled segmentation that includes every foreground pixel in an input binary mask. The outer contour of the result is constrained to be the smallest convex contour that successfully includes all provided foreground pixels. So, not only does it fill in holes, but it also joins disconnected components into a single, filled component.

The algorithm is implemented in the “bwconvhull” function.

Load the matrix “msk” in the attached ‘.mat’ file and display it using imagesc. Observe it contains a very sparse set of foreground pixels.

Run the bwconvhull function on the mask and display the result using imagesc. Observe how the method finds the minimal convex solid segmentation that includes the input foreground pixels.

**What is the name of the geometric shape of the result?**convhullMAT File

**Quiz : Dilation and Erosion**

Q1. This exercise aims to expose you to binary image filtering methods called dilation and erosion. First some background, what are they?

Dilation and erosion are what are called “morphological” filtering methods. They provide another way to filter noise in binary segmentation masks. These operations grow or shrink a small region of pixels around each pixel on the border of the segmentation, hence the names dilation and erosion.

With dilation, a subset of background pixels in the region surrounding every foreground pixel in an input mask is flipped to foreground. The subset for which this occurs is chosen using a so-called “structuring element,” a small binary image that contains the pattern of neighbors to be turned to foreground. Most commonly the structuring element is a 3×3 matrix of all ones. In this case, if any background pixels exist in the the 3×3 grid of pixels that surround each foreground pixel (the 8 pixels in its immediate neighborhood), they are replaced with foreground.

What does this do? Consider foreground pixels that lie on the boundary of the segmentation, adjacent to background pixel neighbors. After dilation, those neighbor background pixels have been flipped to foreground. Repeating this for every foreground pixel that is adjacent to at least one background pixel effectively grows, or “dilates” the segmentation. If small false negative noisy pixels form holes in the segmentation mask, dilation can fill in those holes.

Erosion is very much the complement to dilation. We visit every background pixel. For every foreground neighbor pixel that is marked as a ‘1’ in the structuring element pattern, the value is set to background. So this operation shrinks or “erodes” the segmentation. If there are any false positive noisy pixels lying in background regions of the image, this operation will erase those false positives.

Structuring elements can be customized with different patterns for different behaviors, but the most obvious choice in the size of the structuring element. An erosion using a structuring element formed by a 3×3 matrix of ones will shrink the segmentation boundary by one pixel and erase any foreground region that is as thin as 2 pixels in width (accounting for erosion from both boundaries). An erosion using a structuring element of a 7×7 matrix of ones will shrink the boundary by 3 pixels and erase any foreground region that is as thin as 6 pixels in width.

To limit changes to the overall size of the segmentation, we often perform a dilation, followed by an erosion with the same structuring element. This is called “closing” because the dilation tends to fill in false negative holes and the erosion shrinks the result back down to original size. So it is useful if we want to fill in holes. The complement is first performing and erosion followed by a dilation. This is called “opening,” because it tends to disconnect regions of the foreground that are only connected by a thin set of pixels. It is better for removing false positives.

OK, enough background, let’s try it out with our cameraman image. Load ‘cameraman.tif’ and create a mask by thresholding it less than or equal to 88 (our Otsu threshold), i.e., `1msk = img<=88;`

Erode the mask using the ‘imerode’ function, with the second argument, the structuring element, equal to a 7×7 matrix of ones. For example:`1msk_erode = imerode(msk,ones(7,7));`

Display the original mask, “msk” and the eroded one, “msk_erode” to observe the erosion results.

Dilate msk_erode using the ‘imdilate’ function with the same structuring element. Display the results.

You have performed morphological opening!

**How many connected components are in the result?**

##### Introduction to Data, Signal, and Image Analysis with MATLAB Course Review:

In our experience, we suggest you enroll in Introduction to Data, Signal, and Image Analysis with MATLAB courses and gain some new skills from Professionals completely free and we assure you will be worth it.

Introduction to Data, Signal, and Image Analysis with MATLAB course is available on Coursera for free, if you are stuck anywhere between a quiz or a graded assessment quiz, just visit Networking Funda to get Introduction to Data, Signal, and Image Analysis with MATLAB Quiz Answers.

##### Conclusion:

I hope this Introduction to Data, Signal, and Image Analysis with MATLAB Quiz Answers would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Keep Learning!

#### Get All Course Quiz Answers of MATLAB Programming for Engineers and Scientists Specialization

Introduction to Programming with MATLAB Quiz Answers

Mastering Programming with MATLAB Quiz Answers

Introduction to Data, Signal, and Image Analysis with MATLAB Quiz Answers