1. Engineering
  2. Computer Science
  3. use matlab use the given variables workspace dont neccesary...

Question: use matlab use the given variables workspace dont neccesary...

Question details

Use Matlab.........

Use the given variables....

[] workspace... dont neccesary have to use [].....


TNY = [31,26,30,33,33,39,41,41,34,33,45,42,36,39,37,45,43,36,41,37,32,32,35,42,38,33,40,37,36,51,51];


%problem 2a

nyc_avg = [];

anc_avg = [];

disp(' ');

%problem 2b

nyc_bel_avg = [];

anc_bel_avg = [];

disp(' ');

%problem 2c

anc_abv_nyc = [];

%problem 2d

temp_eq = [];

%problem 2e

equal_temp = [];

%problem 2f

both_abv_frz = [];

%problem 2g

anc_date = [];

anc_temp = [];

disp(' ');

%problem 3


%create a matrix of switch values corresponding to the table given in the

%assignment. The first 2 rows are already filled in.

switches = [0, 0, 0; 0, 0, 1; ...


%Extract the individual columns of the matrix

switch1 = switches(:,1);

switch2 = [];

switch3 = [];

%Write a logical expression to determine if the bulb is on, based on the

%switch states

bulbOn = []; %some logical expression involving switch1, switch2, and switch3; should be a column vector

The maximum daily temperatures (in F) for New York City and Anchorage Alaska during the month of January, 2001 are given in the vectors below 2. TNY = [31,26,30,333339.41,41 .343345.42.363937.4543,36,41,40,373651 ,51] TANCs(3724,28,25,2 1,28,463736,20,24,31,34,40,43,363441,423538.36.3533,424237·26,20,25,31] Write a program that will answer the following Calculate the average temperature for the month in each city How many days was the temperature for the month below the average in each city? On which dates in the month was the temperature in Anchorage higher than the temperature in New York? On which days was the temperature the same in both cities? What was the temperature on the days in part d? On which dates in the month was the temperature in both cities above freezing (above 32 F) What was the date of the last day of the month during which Anchorage was warmer than New York? What was the temperature of Anchorage on that day? a. b. c. d. e. f. g. 3. This problem is similar to one from the in-class exercise, but here you will use array operations to avoid duplicating code. You are analyzing a machine that uses three different switches (SW1, SW2, SW3). The switches are connected to a light bulb, but only certain combinations of these switches will turn the light bulb on. The combinations are given in the table below. (1-electricity can flow, 0 no flow SWI SW2 SW3 Light Bulb 0 0 0 0 Designed to test skills: operators (logical, relational, arithmetic, etc.), operands (binary, numeric, scalars and/or arrays), binary arrays with functions (e.g., mean, sum, find), and binary arrays with other arrays (extraction, multiplication, etc.) Create a matrix of Os and 1s called switches corresponding to the values in the above table. (The first row should be 0 0 0, the second row should be 00 1, etc.) Extract the 3 columns of the matrix to create 3 column vectors, switchl, switch2, and switch3 Write a logical expression to determine the bulb state for each combination of switch states. The result should be a column vector; if you do it correctly, the values will match the values in the last column of the table above. Store the result in a variable called bulbOn. NOTE: If you look at the table carefully, you can infer a relatively simple logical expression that determines whether the bulb is on. HINT: What to the last two rows of the table have in common? What do the other 3 rows for which the bulb is on have in common? a. b. c.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution