% Chapter 2 Basics, Chapter 3 Distinctive Features to Matlab, and 
% Chapter 4 Arithmetic

echo on

%EE202 Homework 1 
%Textbook Chapters 2 to 4
%My Name
%Lab Wed 11:00 to 1:50 pm
%[2.2 page 31] This text file was created by entering: 

format compact
diary ee202_hw1

%When completed enter diary off.
%Edit in any text editor (including Matlabs)
%You must include the question (comments between % *** lines) 

%  *************************************
%1. [Matlab for Engineers Practice Exercise 2.4] Perform the following
%   Matrix operations.
%  *************************************
% a. Define the matrix a = [2.3 5.8 9 4.2] as a Matlab variable.

% b. Find the sine of a

% c. Add 3 to every element in a.

% d. Define the matrix b = [5.2 3.14 2 3.3] as a Matlab variable.

% e. Add together each element in matrix a and in matrix b.

% f. Multiply a by b as defined by the rules of linear algebra.

% g. Read the Error message and redefine b so the matrices can 
%    be multiplied.

% h. Multiply a by b as defined by the rules of linear algebra 
%    without an error message.

% i. Redefine a so it can be squared.

% Learn about the max function by typing.
% help max

%  *************************************
%2 [2.2, 3.2] Apply the max() function to find the maximum of 
%  all entries in the following matrices:
%  *************************************
A = [1 -5 -2; 3 4 -9; -7 2 6];
B = [sin(1) sin(-5) sin(-2); sin(3) sin(4) sin(-9); sin(-7) sin(2) sin(6)];

%  *************************************
%3 [2.1, 2.2, 4.2t, 4.3] Create a script M-file (File > New > M-File) Following the 
%  example in the book, find the arcsine, arccosine, and arctangent of the following
%  matrix.
%  *************************************
C = [0 0.5 ;0.707107 1.0];
%  - Use the display function (page 31) to replace 'ans =' text with the name
%    of the function (Arcsine, Accosine, Arctangent).
%  - The text string 'ans =' must not appear in your answer. 
%  - Your answer must be in degrees not radians.


%  Matlab supports integer data types: int8, int16, int32, and 
%  int64; where 'int' indicates a signed integer saved using 2’ complement
%  notation, containing n bits (8, 16, 32).

%  *************************************
%4 [4.1t, 4.2, 4.4] Calculate the range for each data type using Matlab arithmetic 
%  matrix operators (Table 4.1) and then compare your answers using intmin and intmax 
%  functions as demonstrated on page 43.
%  *************************************
%  - Display all answers as a 1x2 array, where the first element is the minimum
%    value and the second element the maximum value.
%  - for int32 you will need to set the format to long in order to see that
%    the answers are in fact the same.

%  *************************************
%5 [2.2, 4.3]  Using the rand and round functions create a 1x10 array of 
%  random numbers between 1 and 6.
%  *************************************

echo off




