$24
Follow the instructions carefully solve each problem in MATLAB.
PURPOSE: Practice with MATLAB editor and basic operations.
Starting MATLAB
Start MATLAB and change the “Current Folder” to your MATLAB directory.
MATLAB programs should be stored in files, called M-files, which end in the extension ".m" If your program is stored in the file program.m, then typing program at the MATLAB prompt "" will execute all the statements in the program. However, before doing so, be sure that your current directory is the one containing the file program.m. If not, click on the tab labeled Current Directory and change to that directory.
For each problem, create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB1_ problemX.m. Put ALL the commands for the required steps in your script file:
Be sure to clear the display and the memory.
Display your name.
Separate and label different steps using comments.
---------------------------------------------------------------------------------------------------------------------
%{
Class: ENGR15100: Software Tools for Engineers
Instructor: Xiaoli Yang
Author: [Student’s Name]
Assignment: Lab [No.]
File Name: LASTNAME_LAB[No.]_problem[No.].m
Date: [MM]/[DD]/[YY]
%}
%clear screen
clc
%clear workspace
clear
disp('Your Name Here');
disp('');
disp('starting code: ');
%Completing lab x
%your source code here%
---------------------------------------------------------------------------------------------------------------------
Problem 1 (30 points)
Create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB1_problem1.m.
Put all the commands for the following steps in your script file. Separate and label different steps using comments. Unless otherwise specified, do NOT suppress MATLAB’s output in the following steps.
Note the difference between the left and right divisors. Use help to learn more on commands: round, floor ceil (Hint: use pi for π, exp for e)
2/2*3
8*5\4
8*(5\4)
6-2/5+7^2-1*10/2\5-3+2*4
3^2/4
3^2^3
2+round(6/9+3*2)/2
2+floor(6/9+3*2)/2
2+ceil(6/9+3*2)/2
234
-34
-2-4/3
sin1
sin10
sin
PROBLEM 2: Creating Vectors in MATLAB (30 points)
Create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB1_problem2.m. Put all the commands for the following steps in your script file. Separate and label different steps using comments. Unless otherwise specified, do NOT suppress MATLAB’s output in the following steps.
Create a vector variable
Create a vector variable
Create a vector variable by using the MATLAB colon (:) operator (Hint: all the numbers from 5 to -5 in increments of -0.2).
Create a vector variable . The first and last elements of should have the values 0 and 16, respectively. The number of elements of should be the same as that of . Accomplish this step with one line of code using a combination of two built-in functions linspace and length.
Create variables a, b, and c. Assign the scalar values 5, −3.75, and to variables a, b, and c, respectively.
Create a vector variable , based on the variables created in step (5) and their computations
Create a vector variable , based on the variables created in step (5) and their computations
PROBLEM 3: Creating Vectors in MATLAB (40 points)
Create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB1_problem3.m. Put all the commands for the following steps in your script file. Separate and label different steps using comments. Unless otherwise specified, suppress MATLAB’s output in the following steps.
Create a matrix variable such that
Create a matrix variable such that
Utilize the MATLAB colon (:) operator and the built-in function linspace whenever possible.
Create a matrix variable , a 9 x 9 matrix full of 2’s, by using the built-in function ones, such that
Create a matrix variable , a 9 x 9 matrix of all zeros, but with the values
[1 2 3 4 5 4 3 2 1] on the main diagonal, by using the built-in function diag, such that
SUBMITTING YOUR LAB:
Submit your lab by uploading .m files using the Blackboard Assignment feature no later than the date specified.