Lab Sheet 3: MATLAB Functions, Graphics and GUI PDF

Title Lab Sheet 3: MATLAB Functions, Graphics and GUI
Course Data, Audio, Graphics and Image Signal Processing with MATLAB
Institution Cardiff University
Pages 3
File Size 56.5 KB
File Type PDF
Total Downloads 36
Total Views 140

Summary

...


Description

MATLAB, DSP, Graphics Module No: CM0268 Laboratory Worksheet 3: MATLAB Functions, Graphics and GUI Prof. D. Marshall, Dr. Y. Lai

Aims and Objectives After working through this worksheet you should be familiar with: • The basic operation of functions in MATLAB • Create and use MATLAB m-files effectively • Understand some basic MATLAB graphics functions • The basic construction of Graphical User Interfaces in MATLAB • How to call MATLAB Functions from a simple Graphical User Interface. None of the work here is part of the assessed coursework for this module

1

MATLAB Functions, Graphics and GUI MATLAB Functions and m-files For each of the below, create a function, store in an appropriate m-file and then call the function from MATLAB command line: 1. Write a function that takes in a integer n, computes the sum of the series 12 + 22 + 32 . . . such that the sum is as large as possible without exceeding n. Up to two values can be returned, including the number of terms, and (optionally) the corresponding sum. 2. Write a function that takes in a matrix, a row index and a vector such that the function replaces the specified indexed row in the matrix with the vector. The function should return the new matrix. You may wish to check that all inputs are valid for such an operation. (Hint: See Lab Worksheet 2 “Basic Matrix Processing” Question 4.) 3. Write a function that takes in a vector of audio data and amplifies the data by an appropriate factor. The function should return the amplified vector. (Hint: See Lab Worksheet 2 “Audio Data” Questions 3 and 4.) 4. Create a subdirectory in your MATLAB workspace, say tutorial stuff. Move all the above four functions to this subdirectory. By setting your MATLAB path (and without changing directory to the tutorial stuff subdirectory) ensure that MATLAB can call this function from your top level MATLAB directory or indeed any place on your computer system.

2

MATLAB Graphics 1. Plot a MATLAB figure of the cos function over the range 0-20 with a step size of 0.5. • In the same figure now plot a graph of the sin function over the same range and step size so that both graphs are superimposed over each other. • In a separate figure, plot the cos function with a blue dashed line and the sin with red dotted line (again superimposed over each other) • Label the graphs axes with the test X Axis and Y Axes respectively. Give the graph a title Plot of Cosine and Sine • From the command line save the figure as a jpeg file. • In a separate figure, plot the cos function with a blue dashed line and the sin with red dotted line in two subfigures, one above the other. • From the figure window save the figure as a pdf file.

MATLAB Graphical User Interfaces 1. Create a simple calculator Graphical User Interface in MATLAB to enable simple arithmetic. You need only consider simple addition, subtraction, division and multiplication of two numbers.

3...


Similar Free PDFs