Name: ________________________________ Date: _________________________________ MAE 10 – Homework 5 - Loops Note: to complete this homework, you will need to assign values to variables. You can do this by coming up with numbers yourself or using a random number generator. You should also comment ALL your code from now on. 1. Simplify the code by eliminating any unnecessary lines and explain why they are unnecessary: if number > 100 number = 100; else number = number; end References used: 2. Simplify the code by eliminating any unnecessary lines and explain why they are unnecessary: if val >= 10 disp (‘Hello’) elseif val < 10 disp (‘Hi’) end References used: 3. Prompt the user for an integer n and print “MATLAB rocks!” n times. References used: 4. Write a function sumsteps2 that calculates and returns the sum of 1 to n in steps of 2, where n is an argument passed to the function. For example, if 11 is passed, it will return 1 + 3 + 5 + 7 + 9 + 11. Do this using a for loop. Calling the function will look like this: >> sumsteps2(11) ans = 36 References used: MAE 10, nbuswell@uci.edu, This content is protected and may not be shared or distributed.