You are on page 1of 2

Practice Exercise Questions

Notes 1: Consider it as fun part of your learning and don’t take it as a burden or assignment
with a forced deadline. Do exercise by yourself.

Notes 2: Do not consult the solutions directly, make sure you first attempt the questions by
yourself and If you are unable to get it correctly than consult the solution.

Note 3: If feel difficulties in understanding the solutions, post your question in the Q/A section
of the course. Do not forget to mention the question number you are querying about.

Note 4: If you feel you have some exciting questions, please inbox to me and I will add to the
questions list there after review. This will help you fellows to have more practice and fun.

Note 5: Have Fun


__________________________________________________________________________

Q:1. Write a MATLAB function named string_multiplication() that accepts two arguments, i.e., a
string str and an integer N. The function should return one big string that will contain N
instances of the string str with no spaces.

Q:2. Suppose we are given a matrix A with dimensions of m* n. Given another vector say B of
size 1-by-2 which will indicate how much we want to enlarge each element of the matrix A. The
first value in the matrix B (called p), indicates how many rows we want to enlarge each element
of A and the second value in the matrix B (called q) indicate how many columns we want to
enlarge we want to enlarge each element of A. The resultant matrix called Enlarge_matrix will
be of size (m*p)-by-(n*q) in which each element of A has been replicated in p rows and q
columns. Here is an example of this
Suppose

A = [1 2 3;
4 5 6
7 8 9]
And
B = [3 2];
Then the result will look something like this
Enlarge_matrix = [ 1 1 2 2 3 3
1 1 2 2 3 3
1 1 2 2 3 3
4 4 5 5 6 6
4 4 5 5 6 6
4 4 5 5 6 6
7 7 8 8 9 9
7 7 8 8 9 9
7 7 8 8 9 9]

Enjoy MATLAB

You might also like