In: Electrical Engineering
Instructions: 1. Solve the following problems in a MATLAB script. You will be allowed to submit only one script, please work all the problems in the same script (Hint: careful with variables names) 2. Show your work and make comments in the same script (Use %). Please write your name in the first line of the scrip with % 3. It is OK to work with other students, but what you submit should be your own work – not something copied from someone else.
Problem #1 (10 points): Using loops show the following calculation: ? ???? 25 3 ????=1
Problem #2 (15 points): When working with computer, microprocessors or digital systems most of the commands are represented in binary numbers, hexadecimal numbers, ASCII or octal. We want to write a code that do the following a. Inputs are decimal digits from 200 to 400 counting by 10 b. When the counter find a number smaller than 300 the result will be the same number converted into hexadecimal c. When the counter find 300 display “We are at 300 from now on the numbers will be display as binary numbers” d. When the counter find an number bigger than 300 the result will be the same number converted into binary
Problem #3 (25 points): As you make decisions over your 401K, you find one investment opportunity that will draw 09% interest per year added to your account. The trick about this investment is that you will need to cancel the investment as soon as you double the amount of money you put in the first time which could be any amount from $5000 - $7000. You will received statements of the balanced for the total years you invested until the balanced is doubled. Expected from this program: • Initialize balance, year, and interest rate. Your first year is denominated at year 0. • You will need to display the balance with headings “Year” and “Balance” until the balance is twice the original. • Please display the numbers with bank format Example: Initial Balance=4500.00 Year Balance 1.00 4905.00 2.00 5346.45 3.00 5827.63 4.00 6352.12 5.00 6923.81 6.00 7546.95 7.00 8226.18 8.00 8966.53 9.00 9773.52
Problem #4 (35 points): A friend ask you to babysit their 5 year old named Kylo-Ren. After the kid tablet run out of battery and is almost at the point to start screaming, you decide to play a game. Since you are an expert in MATLAB or at least love writing some easy scripts, you decide to work a game for him. You want MATLAB to generate a random integer number that KyloRen will guess. Expected from this program: • Generate a random integer (no higher than 25). Keep in mind that a 5 year old will probably do not want to play a game if it is too long or too short. • Ask the user to input a guess. Please specify how high the guess could be. • Check the guess given for the user. If the guess is too low tell the user: “Kylo-Ren, your guess is too low, please try again and enter a new guess number”. The same thing should happen if the guess is too high. • When the guess is equal to the random number please congratulate Kylo-Ren. • If you can add sounds to the game, Kylo-Ren will be more eager to play over and over again which will give you time to watch one episode of the Big Bang Theory. Plus you can get bonus points. Example: Please enter your guess between 1 and 20: 5 Sorry your guess is too low Please enter your next guess: 15 Sorry your guess is too high Please enter your next guess: 5 Sorry your guess is too low Please enter your next guess: 10 Sorry your guess is too low Please enter your next guess: 12 Sorry your guess is too low Please enter your next guess: 14 Sorry your guess is too high Please enter your next guess: 13 At last! :)
Problem #5 (15 points): You all know I like sports, especially baseball. What is your favorite sport? Expected from this program: • Show the options in a menu form for the user for them to press either Baseball, Football, Soccer, Track and Field, Other, and Quit Survey. • When display a fun fact for each sport as follows o Baseball - display “Bobby Richardson is the only player to win an MVP on the World Series losing team” o Football – display “It takes 600 cows to make one full season’s worth of NFL footballs” o Basketball – display “ Basketball was invented by a YMCA teacher in Springfield, MA” o Soccer – display “FC Barcelona wears UNICEF logo in their shirt while donating 1.5M euros each year – Reverse sponsorship” o Track and Field – display “UNC Charlotte Men T&F Team Won C-USA Championship this year” o Other – display “ Golf: The average golf ball has 336 dimples, Tennis: Tennis balls where change from white to yellow in 1972” o Quit Survey – display “Thanks for participate” Example: Panther: Keep Pounding Broncos are my option Thanks for participate
Problem #6 (20 points): We have set up a limit in current on a piece of equipment to be 0.45 Amps. When the system is running data is gather in the DAQ. The system generates a vector of 10 random numbers in one single column. The control system is comparing if the values of the result currents are higher than the limit set for the supplier. We need to project the results into a monitor for easy understanding and to take action over the equipment. If one of the parameters in the vector has a value higher than the limit, we will need to display a message that say “There is at least one current value measure above the limit”, if this is not true, please display “All values are below the limit. You can proceed with your data acquisition”.
for x=200:10:400
if x<300
y=dec2hex(x)
elseif x==300
disp('We are at 300 from now on the numbers will be display as
binary numbers');
else
y=dec2bin(x)
end
end
%-------------------
x=randi(25);
y=input('select a guess between 1 and 25: ');
while (abs(y-x)>5)
if y>x
disp('your guess is too high, try again');
elseif y<x
disp('your guess is too low, try again');
end
y=input('select a guess between 1 and 25: ');
end
disp('you have guessed it exactly ');
>> m61
y =
C8
y =
D2
y =
DC
y =
E6
y =
F0
y =
FA
y =
104
y =
10E
y =
118
y =
122
We are at 300 from now on the numbers will be display as binary numbers
y =
100110110
y =
101000000
y =
101001010
y =
101010100
y =
101011110
y =
101101000
y =
101110010
y =
101111100
y =
110000110
y =
110010000
select a guess between 1 and 25: 22
your guess is too high, try again
select a guess between 1 and 25: 1
your guess is too low, try again
select a guess between 1 and 25: 5
your guess is too low, try again
select a guess between 1 and 25: 10
your guess is too low, try again
select a guess between 1 and 25: 15
you have guessed it exactly
>>