Starting from:
$30

$24

Laboratory #4 Solution

PURPOSE: Learn about Relational/Logical Operators, Expressions, Functions




For each problem, create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB4_ 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: FIRSTNAME_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 (40 points):

Create a variable named dayTemps_CHI and assign to it a vector whose elements are the following daily temperatures (in °F) recorded for Chicago in the month of August. 

[75 79 86 86 79 81 73 89 91 86 81 82 86 88 89 90 82 84 81 79 73 69 73 79 82 72 66 71 69 66 66] 


Create a variable named dayTemps_SF and assign to it a vector whose elements are the following daily temperatures (in °F) recorded for San Francisco in the month of August. 

[69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68 68 69 71 70 89 95 90 66 69] 


Determine how many days San Francisco’s temperature was above average. 

Compute how many days Chicago’s temperature was in the range [62°F, 78°F]. 

Compute how many days San Francisco’s temperature was cooler than 72°F OR warmer than 80°F. 

Compute how many days Chicago’s temperature was NOT between 70°F and 90°F, inclusive. 

Compute how many days San Francisco’s temperature was NOT colder than 73°F AND NOT
warmer than 89°F. 

Compute Chicago’s temperatures that are warmer than 84°F but cooler than 90°F.
Compute San Francisco’s temperatures that are warmer than 65°F, cooler than 72°F, but NOT 69°F. 

Compute on which day(s) San Francisco’s temperature was warmer OR the same as the temperature in Chicago? 

Compute on which day(s) the temperature was the same in both cities. 

problem 2 (60 points):

Create a variable named x and assign to it a row vector whose elements equally spaced values starting with -15, ending at most with 15, in steps of 0.1. 

Create a variable named f. This variable is to store a row vector whose elements are those obtained by evaluating the following piecewise function below for every element of row vector x. 

 

Compute the elements of row vector f using a combination of logical operations, relational operators, logical indexing, and mathematical operations.

Plot f vs. x in a Figure Window named Figure 1. Format the plot according to the following specifications.
Title the plot using the string ‘f(x) vs. x’. 

Label the graph’s horizontal axis with the string ‘x’.
Label the graph’s vertical axis with the string ‘f(x)’.
Activate the major access grid to aid in visualizing the plot.
SUBMITTING YOUR LAB:

Submit your lab by uploading .m file using the Blackboard Assignment feature no later than the date specified.

More products