matlab take screenshot on how u do it in matlab so i can do
(matlab) take screenshot on how u do it in matlab !!! so i can do as what u did step by step
EE 200: Computer Utilization, Fall 2016
Assignment 3
Assigned on Sep 12 (Mon)
Due on Sep 19 (Mon) at 3:30pm
Note: This copy is for your reference. The online version diers only slightly.
Submit the answers to the links on Blackboard.
1. (4 points) A student was rolling a dice to decide what to do in the next hour:
If it\'s 1, he\'d exercise.
If it\'s 2, he\'d hang out with friends.
If it\'s 3, he\'d watch TV.
If it\'s 4, he\'d play with phone apps.
If it\'s 5, he\'d read the textbook.
If it\'s 6, he\'d do homework.
However, he didn\'t follow through with the rst choice; instead, he kept on rolling the dice 10 times. Please simulate
this process and generate a sequence of 10 random integers between 1 and 6 (including 1 and 6). Please implement it
in two ways, using rand function and randi function, respectively. While using rand function, you need to use a proper
rounding function, and please select one that makes all the 6 choices equally likely to happen.
2. (4 points) Generate the following matrix using colon expression and/or linspace function. The last row is of identical
elements, and you can use ones and repmat functions, too. Hint: You may try to generate each row individually, and
then use proper separators to put the rows into a single matrix. Ignore the box for now, which is used next.
5 4 3 2 1 0 -1
0.8 1.1 1.4 1.7 2.0 2.3 2.6
16 16 16 16 16 16 16
3. (2 points) Given the matrix dened in the previous problem, please retrieve the value of the elements that are in the
section in the box from the matrix variable you dened above.
4. (Bonus: 1 point) We need to dene a matrix (database) below, would you like to type it in the command window? Can
you imagine what would be a more convenient way? We will see whether the programmers of Matlab/Octave think the
same as you do in our next class. :-)
Species Sepal length Sepal width Petal length Petal width
1 5.1 3.5 1.4 0.2
1 4.9 3 1.4 0.2
1 4.7 3.2 1.3 0.2
2 7 3.2 4.7 1.4
2 6.4 3.2 4.5 1.5
2 6.9 3.1 4.9 1.5
3 6.3 3.3 6 2.5
3 5.8 2.7 5.1 1.9
3 7.1 3 5.9 2.1
5. After you nish your assignment, please copy your commands with answers and paste them to a text le (in .m or .txt
format), and upload the text le (no need to zip) to the link in Part 2 of Assignment 3.
Solution
(1)
MATLAB code:
clear all
 close all
 clc
 for i=1:10
 %first case formula
 r1(i) = round((6-1).*rand(1,1) + 1);
 %second case formula
 r2(i)=randi(6,1);
 end
 r1
 r2
sample output
 r1 =
1 4 4 4 5 4 3 5 6 3
 r2 =
2 5 3 2 2 2 4 1 5 3
>>


