1. Write a Matlab™ program to calculate the sine of an angle from its series. For an angle of 5
radians and using 10, 15 and 25 terms in the series, compare this to values produced by the sine
(i.e. sin()) function provided in Matlab™. Use 15 digits of precision when comparing these two
numbers. Put comments in your program so that the operation is readily understood.
The series for computing the sine of a value is
Matlab functions and features
2. State how a compiler or interpreter such as Matlab™ distinguishes between a function and a
3. Indicate which of the following variable names are not legal variable names in Matlab, and
explain why. Indicate, with reasons, which ones are legal but not recommended.
(i) A65 (ii) a6b (iii) spectra91 (iv) exit (v) 78Si
(v1) High Five (vii) price$ (vii) my()book (ix) pi (x) a_5
(xi) cos30 (xii) sin (xiii) pi3 (xiv) Pi (xv) 7_v
4. Illustrate with a short code how the ‘switch’ structure might be replaced by ‘if’ statements.
5. Determine the data types of the parameters c and C in the following
>> a=[1 9 6
4 7 3
7 5 9]
>>b=[23 57 82
67 15 98]
6. Write an anonymous function that computes the equation for the stiffness, , of a prismatic
cantilever beam of rectangular cross section
Where is the Young’s modulus, is the thickness, is the breadth (or width) and is the
length of the beam.
Generate a matlab program that uses this anonymous function to compute the stiffness of an
aluminum cantilever of length 250 mm, width 25 mm for thickness values ranging from1 to 4 mm in 100
steps. Plot this as a graph with labels.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
%The format to use
%The number of terms to use
Number_of_terms=[10 15 25];
%The angle to use
%First display the answer using the Matlab function sin:
%display_string: the string which we use to display the answer
display_string=['The value of sin(' num2str(x) '):' num2str(sin(x),15)];
%It should display: The value of sin(5):-0.958924274663138
%the approximation is as a series, initialize the first term to be zero
%and further add to it.
%The number of terms at this time
%Construct the values in the series and add to the
%At the end of this loop all the terms have been added.
%Diplay the result:
display_string=['The approximate value with ' num2str(N) ' terms: ‘ num2str(approximate_sin_value,15)];
%Output from the program should be:
% The value of sin(5):-0.958924274663138...