Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

homework and lab for matlab 243

EEC 243 Introduction to Programming – MATLAB

Lab 5: Loop Statements and Vectorizing Code

Tasks

  • Execute this script and be amazed by the results!You can try more points to get a clearer picture, but it may take a while to run.
  • It is good programming style to always use a for loop when the number of times to repeat the action is known.The following code uses a while loop that mimics what a for loop should do.Re-write it using a for loop that accomplishes exactly the same thing.
  • Write a script that will prompt the user for a quiz grade and error-check until the user enters a valid quiz grade.The script will then echo print the grade.For this case, valid grades are in the range from 0 to 10 in steps of 0.5.Do this by creating a vector of valid grades and then use any or all in the condition in the while loop.
  • Write a script beautyofmath that produces the following output.The script should iterate from 1 to 9 to produce the expressions on the left, perform the specified operation to get the results shown on the right, and print exactly in the format shown here.
  • (Optional) Write a “Guess My Number Game” program.The program generates a random integer in a specified range, and the user (the player) has to guess the number.The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again.

clear

clf

x = rand;

y = rand;

plot(x,y)

hold on

for it = 1:10000

choic = round(rand*2);

if choic == 0

x = x/2;

y = y/2;

elseif choic == 1

x = (x+1)/2;

y = y/2;

else

x = (x+0.5)/2;

y = (y+1)/2;

end

plot(x,y,’r*’)

hold on

end

myprod = 1;

i = 1;

while i <= 4

num = input(‘Enter a number: ‘);

myprod = myprod * num;

i = i + 1;

end

Answer:

Answer:

>> beautyofmath

1 x 8 + 1 = 9

12 x 8 + 2 = 98

123 x 8 + 3 = 987

1234 x 8 + 4 = 9876

12345 x 8 + 5 = 98765

123456 x 8 + 6 = 987654

1234567 x 8 + 7 = 9876543

12345678 x 8 + 8 = 98765432

123456789 x 8 + 9 = 987654321

Answer:

The basic algorithm is:

  • The program starts by printing instructions on the screen.
  • For every game:
  • After all games have been played, print a summary showing the average number of guesses.
  • the program generates a new random integer in the range from MIN to MAX.Treat MIN and MAX like constants; start by initializing them to 1 and 100
  • loop to prompt the player for a guess until the player correctly guesses the integer
  • for each guess, the program prints whether the player’s guess was too low, too high, or correct
  • at the conclusion (when the integer has been guessed):
  • print the total number of guesses for that game
  • print a message regarding how well the player did in that game (e.g the player took way too long to guess the number, the player was awesome, etc.).To do this, you will have to decide on ranges for your messages and give a rationale for your decision in a comment in the program.

Assignment 5

  • Prompt the user for an integer n and print “MATLAB rocks!” n times.
  • Given the following loop:
  • Trace this to determine the output, and then enter it to verify your answer.
  • Write code that will prompt the user for 5 numbers, and store them in a vector.Make sure that you preallocate the vector!
  • Write a function myones that will receive two input arguments n and m and will return an n by m matrix of all ones.Do NOT use any built-in functions (so, yes, the code will be inefficient).

Answer:

while x < 10

action

end

  • For what values of the variable x would the action of the loop be skipped entirely?
  • If the variable x is initialized to have the value of 5 before the loop, what would the action have to include in order for this to not be an infinite loop?

Answer:

Answer:

for i = 2:2:6

fprintf(‘%d: ‘, i)

for j = i:-1:1

fprintf(‘*’)

end

fprintf(‘n’)

end

Answer:

Answer:

Answer:

myones.m

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW


Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.