Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Matlab program that starts with a total of zero and uses a WHILE loop to keep adding a random integer between -1

Write a Matlab program that starts with a total of zero and uses a WHILE loop to keep adding a random integer between -1 and +2 (i.e., either -1, 0, +1 or +2) to the total, until the total is greater than or equal to 100,000. The program should display the total as it runs and when finished tell the user how long it took to reach that total. Hint: one approach is for the program to stay in the WHILE loop while a variable called total hasn't been reached yet. Write a Matlab program that creates uses a 1 x 100 array of numbers and fills it with integers which count up from 1 to 50 and then down from 49 to 1 again (i.c., 1 2 3 4 ... 47 48 49 50 49 48 47 4 3 2 1). It should display the array on the screen.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions