The question marked with * (asterisk) will be assessed for tutorial participation. You will need to bring
Question:
The question marked with * (asterisk) will be assessed for tutorial participation. You will need to bring your solution to this question to your tutorial in Week 4; in particular, you should bring a printout of your MATLAB program (together with the input and output), or have it all ready on your computer screen to show your tutor at the beginning of the tutorial.
1. Enter and execute the following MATLAB program.
% Find y values in a certain range clear format compact count=0; for x=-4:0.2:4 y=sin(x); if y>=0.5 count=count+1 disp(y) end end What does the final value of count mean? Modify the program to find the number of y values
(a) that equal 0
(b) that are not equal to 0
(c) that are in the interval [0, 0.5]
(d) that are either greater than 0 5 or less than —0.1
Recall the relational operators
< <= > >= == and the logical operators - (i.e. not) & (i.e. and)
I (i.e. or)
2. Enter and execute the following program.
Y. Find y values in a certain range x=-4:0.2:4; y=sin(x); indset=find(y>=0.5) numval=length(indset) disp('Required values of y are: ') y(indset)
What does the value of numval mean? Modify the program to find the elements of y that are in the interval [0,0.51.
3. * Each week a builder makes an order of doors from a supplier. The doors normally cost $60 each, but the supplier gives a 10% discount for any order of 30 or more doors. The orders for the first 8 weeks of the year are given in the vector:
orders = [20 40 15 30 25 45 10 35]
(a) Write a MATLAB program using a for loop and if statement to find the total cost of the doors ordered.
(b) Extend your program using the find command to find which weeks the builder obtained a discount.
Fundamentals of biochemistry Life at the Molecular Level
ISBN: 978-0470547847
4th edition
Authors: Donald Voet, Judith G. Voet, Charlotte W. Pratt