HW-5 MATH 9Due: Thursday May 9th, at 10:00am
Write a code by considering all following items.
i)
Write your name and ID in the first line.
ii)
Named the code to be Rep_Elemt24 on which 24 is two last digits of your
ID.
iii)
Do not print anything unless the ones that are requested below.
iv)
Do not change any name that is defined below.
1) Define a function as; [ RE ] = Rep_Elemt( A ), where A is a vector to be
defined in commend window.
2) Find vector B with its elements to be unique elements of A. For example if A
= [1 1 2 3 5 3 1 2 7], then B = [1 2 3 5 7].
3) For each element of A, find out how many times is repeated. That is, for
above example, 1 is repeated 3 times, 2 is repeated 2 times, 3 repeated 2
times, 5 repeated 1 time and 7 repeated 1 time. Plug these repeated times in
vector RE. In above example RE = [3 2 2 1 1].
4) Print (report) B and RE.
5) Plot B verses RE with following options
set(gca,’FontSize’,16)
title(‘Elements VS Number of Repeated’)
xlabel(‘Elements’)
ylabel(‘Number of Repeated’)
6) Check your code with vector A to be defined in commend window as:
A = randi(20,[1,100]).
7) Copy your outputs B and RE leading with % in the end of your code. Of
course, you do not need to copy and pest the graph.
Hint: Search to find an appropriate commends for item 2 and 3. Using these
commends the code will be very easy. Alternatively, you can use loop (for)
commends too, but would be complicated.