Question
2. Formatting and significant digits. Lets define two variables. x=1/3, and y=0.333333. a. When you look in the workspace pane or if you type x
2. Formatting and significant digits. Lets define two variables. x=1/3, and y=0.333333. a. When you look in the workspace pane or if you type x and y into the command prompt, what do you see? Do you think x and y are really equal? b. Now change the format to long, and type x and y into the command prompt. Now do you think they are equal? c. Change the format back to short and determine x-y. Comment on your answer.
3. Rounding. Matlab allows us to round numbers in different ways. Lets try it out. a. Try out round(3.1), round(3.49), round(3.5), and round(3.999). What does round do? b. Now try the ceil function. What is ceil(3.000000001), ceil(3.9999999999) and ceil(2.999999999)? c. Repeat part b but use the floor function. How do ceil and floor work? d. rem can be a useful function to find remainders. Try out rem(3,1), rem(3,2), and rem(3,3). Describe how you think rem works.
4. Random numbers. First type rng('shuffle') to get a new seed for the random number generator in Matlab. For each series of random numbers below, please determine the Matlab command that would give this series, using only the rand function to generate the random number (not randi). For example, a random number between 0 and 1 would just be rand(1). a. A random number between 0 and 5. b. A random number between 3 and 5. c. A random integer between 11 and 25. d. A random integer between -15 and -6. e. A random odd integer between 0 and 100.
5. We havent discussed plotting yet, but lets try out a few very simple exercises. You can paste the plots into your word file directly. a. Try out plot(2,4). What does this do (you may have to squint)? Now try (plot(2,4, '*'). b. Try plot(rand(10,1)). What do you think is happening? c. You can use the command help plot to find formatting tips, for example, you can try plot(rand(10,1),'r--d'). What do you think the r, --', and d do to the format?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started