For the following, write the commands in a script file leaving the semi-colon off so the answers print in the command window. Turn in the script and output. Output should include:
a. number of elements in ts1
b. number of elements in ts2
c. first element in ts1
d. first element in ts2
e. sum of ts1
f. minimum value in ts1
g. mean of ts1
h. first element in tsRev
i. last element in tsRev
Create a script that first creates two variables, ts1 and ts2. Use linspace to create ts1 and the : operator to create ts2.
- Both ts1 and ts2 should start at 0 and end at 1, and have (approximately) 100 elements.
- Check that the number of elements is approximately correct using the command length on both variables
- Check that the first element of each array is, indeed, zero, by accessing the first element using the ts(1) syntax.
- Check that the last element of each array is, indeed, 1, by accessing the last element of each array
- Hint: What do you put in the () to get the last element?
- Calculate the sum, min and average (mean) of the ts1 array
- What should the min value be?
- What should the mean value be?
- Use linspace to create an array tsRev that has the same values as ts1, but in reverse order.
- Check the first and last values of tsRev.
This question belongs to MATLAB software and discusses about application of MATLAB in mathematics to find out the maximum and minimum values in a group of given elements.
Download Full Solution