Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

HW1 - MATLAB

The purpose of this homework assignment is to help you practice the concepts we have learned and prepare youfor the quizzes. It     will be gradedfor effort and completeness, notfor correctness, so that you use this as an opportunity to truly practice and learn the    material without concernfor how this assignment will affect your grade.  Therefore, to truly learn, please complete this assignment in an honest manner, abiding by the acceptable and unacceptable behaviors described below.

Acceptable behaviors for this assignment include:  Asking your professor or TAs for clarification, consulting the resources posted in Canvas, discussing with your teammates

Unacceptable behaviors for this assignment include: Obtaining or copying solutions from anywhere or from others, either in person or online; sharing or posting solutions, either in person or online; asking someone to complete the assignment for      you

AFTER THE HW DUE DATE, SOLUTIONS WILL BE POSTED IN THE CANVAS ORGANIZATION.  PLEASE COMPARE YOUR   SOLUTIONS TO THE SOLUTION FILE, TO ENSURE YOU ARE UNDERSTANDING THE MATERIAL. BECAUSE IT IS GRADED ON COMPLETION, A HIGH SCORE DOES NOT NECESSARILY MEAN YOU DID IT CORRECTLY.  THEREFORE, PLEASE        COMPARE YOUR SOLUTIONS TO THE POSTED SOLUTION FILE.

This homework assignment will help you with thefollowing learning objectives:

-       Use help in MATLAB

-       Create and run m-files

-       Save andfind m-files

-      Incorporate comments in a code

-       Create and use variables to represent scalars as well as one-dimensional and two-dimensional arrays in MATLAB

-       Use MATLABfor basic mathematical operations including these built-infunctions: sqrt, abs, exp, log, log10, sum, prod, min, max, sort, rem, mod

-       Create arrays using the linspace and colon methods, as well as ones and zeros

-       Use size and length to get the dimensions of arrays

-      Refer to individual elements in an array

1.    Create a MATLAB script that will do the items below.  Unless you are specifically asked to display something, please make sure your outputs are suppressed (not displayed to the command window):

a.    Display this sentence to the command window:  “I, (YourName), certify that I have completed this assignment in an honest manner.”  Use the disp command and place the sentence inside ‘ ‘ as follows: disp(‘your sentence’).

b.    Create a variable, VarLog, with the log (base 10) of 5 (use a built-in function).

c.    Create a variable, VarExp, which stores the result of 43 .

d.    Create a variable, VarE, which stores the result of e4 (use a built-in function).

e.    Create the variable Data (below), and display it to the screen.

0  3  4  7

Data =     1  5  8  9

4  2  3  1

f.     Display the element in the second row, first column of the variable Data to the command window.

g.    Create the variable sizeData, which has the number of rows and columns of the variable Data (use a built-in function).

h.    Create the variable sqRoot, which stores the result of calculating the square root of 144 (use a built-in function).

i.     Create the variable absVal, which stores the result of calculating the absolute value of -75 (use a built-in function), and display it to the screen.

j.     Use the linspace command to create ArrayLin, that starts at 3, ends at 30, and has exactly 15 elements in the array .

k.    Use the colon method to create ArrayCol, that starts at 3, ends at 30, and has a step size of 2.5.

l.     Use the appropriate built-in function to create MatOne, which is a 3x2 matrix in which all elements are the number 1.

m.   Use the appropriate built-in function to create MatZero, which is a 5x3 matrix in which all elements are the number 0.

2.    Using pen and paper, find the solutions to the items below.  Then, find those solutions using MATLAB and verify your           results.  Add your MATLAB code (what you did to verify the solutions) to the script you created for Part 1, and make sure all outputs are suppressed.

a.    Use the colon notation to create variable Y, which is equal to the indicated portion of the variable Data.

Y =   4

8

3

b.    Use the colon notation to create variable Z, which is equal to the indicated portion of the variable Data.

Z =  3     4     7

5     8     9

c.    Use the colon notation to create variable S, which is equal to the indicated portion of the variable Data.

S  = [5     9]

d.    Find sum(Z).

e.    Find prod(Z).

f.     Given A, B and C, use a built-in function to determine how many elements there are in B (the length of B).

A = 3   -2   1        B = 4   7   2          C = -2

-5

-6

g.    What is the minimum value in B?  Use a built-in function to determine this.

h.    What is the maximum value in C? Use a built-in function to determine this.

i.     What is the maximum value in A, and in which position is it located?  Use a built-in function to determine this.

j.     What is sort(A)?

Include a comment with your name at the top.

Include comments and whitespace so that your program is neat and understandable to anyone who reads it.

This is an individual submission.  Please name your file InstructorName_ClassTime_HW1_UserName (for example:                       Balawejder_5pm_HW1_abc123) and submit your file at the start of class, through the assignment link in your section’s Canvas site.