Question

In: Computer Science

A) Suppose owls is a MATLAB array with 251 rows and 51 columns representing the number...

A) Suppose owls is a MATLAB array with 251 rows and 51 columns representing the number of owls counted in the 251 counties in Texas had over the years 1960-2010. Write code to define a MATLAB variable to find the median number of owls counted in each county.

B) Suppose cattle is a MATLAB array with 251 rows and 51 columns representing the number of cattle in the 251 counties in Texas had over the years 1950-2000. Write code to define a MATLAB variable that contains the median number of cattle counted each year.

C) Suppose the Texas Department of Public Health is tracking the number of tuberculosis deaths in an array (TBDeaths, 30 by 48), representing the number of new tuberculosis related deaths in the 30 least populous counties (in order low to high) in Texas over the years 1960-2017. Write code to define a MATLAB variable that contains the overall minimum number of TB deaths cases in these counties during the recording period.

D) Suppose the Texas Department of Motor Vehicles is tracking the number of car, truck and motorcycle (respectively) crashes in Texas over the years 2000 to 2019 in an array TXCrash (3 x 20).


Write code to define a MATLAB variable that contains the number of truck crashes for the year 2019.

Solutions

Expert Solution

Code

owls = zeros(251,51);
owls = randi([0,100],size(owls)); %Choose random number of owls in 251 countries ranging from 0 to 100.
i=1;
while(i<52)
owls_median(i,1) = median(owls(i,:));
i=i+1;
end

cattle = zeros(251,51);
cattle = randi([0,100],size(cattle));
cattle_median = median(cattle);

TBDeaths = zeros(30,48);
TBDeaths = randi([0,100],size(TBDeaths));
TBDeaths_LowtoHigh = sort(TBDeaths);
i=1;
while(i<31)
TBDeaths_minimum(i,1) = min(TBDeaths_LowtoHigh(i,:));
i=i+1;
end

TXCrash = zeros(3,20);
TXCrash = randi([0,100],size(TXCrash));
TXCrash_truck_2019 = (TXCrash(2,end));

===============================================

Results


Related Solutions

Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given).
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given). Important: Next, the expression "a single line of code" implies a single command or equality. In other words, the code: X=A+1; X=X+B; is considered to be TWO lines of code, even though it can be written as one line. (a) (3%) Write a single line of code which saves the first two rows of array A...
c++ program to calculate the sum of the rows and the columns in a multidimensional array
c++ program to calculate the sum of the rows and the columns in a multidimensional array
Write a program that read an array consists of 4 rows and 4 columns, then computes...
Write a program that read an array consists of 4 rows and 4 columns, then computes and print the sum of the elements above and below the main diagonal. (WITH C++)
Write a script to display the following patterns on the screen. Number of rows and columns...
Write a script to display the following patterns on the screen. Number of rows and columns are taken from the command arguments; if they are missing, set default to 3 (rows) and 4 (columns). Hint: you will use a nested loop. **** **** **** a) Display the source code in an editor (#4-11) b) Execute your script in the terminal, and display the command and the result (#4-12)
JAVA If a user inputs a specific number of rows, columns and sections for a rectangle...
JAVA If a user inputs a specific number of rows, columns and sections for a rectangle using three symbols, how would you print using for loops and a string? Not using an array Example: If 4 was inputted for rows, 12 was inputted for columns, 6 was inputted for sections, and the following symbols (that are all chosen by the user) were “$” “*” and “%” the following would print: $$**%%$$**%% $$**%%$$**%% $$**%%$$**%% $$**%%$$**%% Has to account for all numbers...
JAVA LANGUAGE Write a program that declares a 2-Dimensional Array with 4 rows and 4 columns...
JAVA LANGUAGE Write a program that declares a 2-Dimensional Array with 4 rows and 4 columns to store integer values, and then: fill elements with values as the sum of its column index and row index, e.g., the element at row index 0 and column index 0 is (0+0=0), the element at row index 0 and column index 1 is (0+1=1). compute the sum of elements at the second row. compute the sum of elements at the third column. compute...
Given an m × n matrix (or 2-dimensional array) whose rows and columns are sorted, so...
Given an m × n matrix (or 2-dimensional array) whose rows and columns are sorted, so A[i][j]≤ A[i][j+1] and A[i][j]≤ A[i+1][j] Write an algorithm that searches for a specific value in the matrix.
MATLAB Create a matrix named P which has 2000 rows and 100 columns of all zeros....
MATLAB Create a matrix named P which has 2000 rows and 100 columns of all zeros. Replace the zeros in rows 46-58 and columns 3-18 of matrix P from the previous question with ones.
1 How can we specify the number of rows and columns in a grid layout? 2....
1 How can we specify the number of rows and columns in a grid layout? 2. What happens when we don't have enough items to be displayed in a grid layout with a specified size? 3. How can we specify a grid layout component to occupy more than one columns or rows? 4. What happens if the components in a linear and grid layout exceed the layout size? How can we handle this problem so that all components can be...
[In MATLAB] We have an array of seven values for a number x : [ 1.92,...
[In MATLAB] We have an array of seven values for a number x : [ 1.92, 0.05, -2.43, -0.02, 0.09, 0.85 . 0.06] . We consider any data value in the range -0.1 <x<0.1 as erroneous value. We want to remove all such values and replace them with zeros at the end of the array. Write a script using a for loop with conditional statements Write a script using the find function
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT