Question

In: Advanced Math

**MATLAB 8)The structure for students' quiz data for a class is organized as below ID number...

**MATLAB

8)The structure for students' quiz data for a class is organized as below

ID number Quiz
44 7
33 5.5
37 8

write a script to print the students' data by ascending order of ID number. The index vector method must be used and the MATLAB functions for sorting CANNOT be used.

9)In a physics measurement, the density of the water is measured at different depth. Here are the depth vector and density vector.

depth=[100,200,300,400,500]

density=[6.1,6.9,8.0,8.8,10.2]

USE polyfit to fit the data with 1,2, and 3 degree curves and use subplot to over plot your fitting curves on your original data.

Solutions

Expert Solution

MATLAB Code:

close all
clear
clc

% Problem 8
id = [44 33 37];
quiz = [7 5.5 8];
for i = 1:length(id)
for j = i+1:length(id)
if id(i) > id(j)
temp = id(i);
id(i) = id(j);
id(j) = temp;
  
temp = quiz(i);
quiz(i) = quiz(j);
quiz(j) = temp;
end
end
end
disp('After Sorting:')
disp('ID:'), disp(id)
disp('Quiz:'), disp(quiz)

% Problem 9
depth = [100 200 300 400 500];
density = [6.1 6.9 8.0 8.8 10.2];
depth_ = min(depth)-10:0.1:max(depth)+10;
p1 = polyfit(depth, density, 1); y1 = polyval(p1, depth_);
p2 = polyfit(depth, density, 2); y2 = polyval(p2, depth_);
p3 = polyfit(depth, density, 3); y3 = polyval(p3, depth_);

figure
subplot(131), plot(depth, density, 'o', depth_, y1)
xlabel('Depth'), ylabel('Density')
title('Degree 1 Polynomial')

subplot(132), plot(depth, density, 'o', depth_, y2)
xlabel('Depth'), ylabel('Density')
title('Degree 2 Polynomial')

subplot(133), plot(depth, density, 'o', depth_, y3)
xlabel('Depth'), ylabel('Density')
title('Degree 3 Polynomial')

Output:

After Sorting:
ID:
33 37 44
Quiz:
5.5000 8.0000 7.0000

Plot:


Related Solutions

In Chapter 8, you created a Salesperson class with fields for an ID number and sales...
In Chapter 8, you created a Salesperson class with fields for an ID number and sales values. Now, create an application that allows a user to enter values for an array of seven Salesperson objects. Offer the user the choice of displaying the objects in order by either (I)D number or (S)ales value. ----------------------- Salesperson.java public class Salesperson {    private int id;    private double sales;    Salesperson(int idNum, double amt)    {       id = idNum;       sales = amt;    }    public int getId()...
The data below are scores of 8 randomly selected statistic students, and the number of hours...
The data below are scores of 8 randomly selected statistic students, and the number of hours they studied for their quiz. x (hours) 3 2 4 6 3 2 4 8 y (scores) 65 60 85 90 71 57 83 96 a. Calculate the linear correlation coefficient and coefficient of determination and explain its meaning.    b. Find the equation of the regression line and use it to predict the quiz score of a student who studied 5 hours. c....
In a class of 25 students the average grade on a quiz is 16.85, with a...
In a class of 25 students the average grade on a quiz is 16.85, with a sample standard deviation of 4.75. The grades are known to be normally distributed. a. Determine the standard error of the mean. b. Determine the 98% confidence interval for the class grades. c. If you wanted a narrower interval, would you increase or decrease the confidence level?
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a doubleannual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. public class DemoSalesperson { public static void...
There are 25 students in a class. The lowest quiz score is a 5. The average...
There are 25 students in a class. The lowest quiz score is a 5. The average quiz score is 14, median is 15, and SD is 3. If the student who got a 5 has their grade changed to a 10, what happens to the average, the median, and the SD, respectively? Answer in detail.
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name,...
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name, last name, and hourly pay rate (use of string datatype is not allowed). Create an array of five Employee objects. Input the data in the employee array. Write a searchById() function, that ask the user to enter an employee id, if its present, your program should display the employee record, if it isn’t there, simply print the message ”Employee with this ID doesn’t exist”....
create a public class and a main class to deletebyStudentID number with get ID and getStudentByName...
create a public class and a main class to deletebyStudentID number with get ID and getStudentByName in public class. when the user is prompted to search for the student and delete them by their. ID has seven digits and 6 students each. Ex. Delete student by their ID         Enter students name and their ID         Vanessa,         1111-111         Vanessa is now deleted
Below are data for the number of students in each of four age groups that are...
Below are data for the number of students in each of four age groups that are enrolled in several local schools: Age Group Franklin School Lowell Public School JeanneD’arc School International School Toddlers (1 – 4 yrs.) Pre-adolescents (5 - 8 yrs.) Adolescents (9 - 12 yrs.) Teens (13 - 18 yrs.) 0 56 131 0 36 52 51 64 0 24 98 111 34 41 52 69 Using the included data file and SPSS, create a separate Pie Chart...
Question 1 - Create a class named Student that has fields for an ID number, number...
Question 1 - Create a class named Student that has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. A Student also has a field for grade point average. Include a method to compute the grade point...
Suppose that a lecturer gives a 10-point quiz to a class of five students. The results...
Suppose that a lecturer gives a 10-point quiz to a class of five students. The results of the quiz are 3, 1, 5, 9, and 7. For simplicity, assume that the five students are the population. Assume that all samples of size 2 are taken with replacement and the mean of each sample is found. Questions: Calculate the population mean and standard deviation Suppose that you obtain at least 20 random samples of size 2. From data obtained by you,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT