Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB CODES PLEASE! San Diego State University - Department of Electrical and Computer Engineering EE300 - Computational and Statistical Methods of Electrical Engineers Summer 2022

MATLAB CODES PLEASE!

image text in transcribedimage text in transcribed
San Diego State University - Department of Electrical and Computer Engineering EE300 - Computational and Statistical Methods of Electrical Engineers Summer 2022 - MATLAB Project The attached Excel file contains a data set on the displacements and horsepowers of numerous cars. We want to examine if the displacement of a car has correlation with the the car's horsepower. You should define a as a vector recording the data for the displacements and y as a vector recording the horsepowers. You can load the data from the Excel file as follows: T = readtable('car-dataset.xlsx'); A = table2array (T); should be the first column of A and y should be the second column of A. Perform the following tasks: 1. (2pt) Find the (sample) means of the displacements and the horsepower and store them as mX and my . . (1pt) You may wish to try the MATLAB functions mean(r) and mean(y). . (1pt) Write your own function my-mean(r) that takes input as a data vector z and returns its mean m.X. This function should provide the following result mX = where / is the length of the data vector r and ; is its ith element. Compare the result you get from my-mean(x) and my-mean(y) with mean(x) and mean(y). Notes: i.) You're not allowed to use MATLAB's built-in sum function here. You have to use "for" loop to calculate the sum, and ii.) Your function must not hard-code a fixed number N for the input, it must work for any data vector c. 2. (2pt) Find the (sample) standard deviation of the displacement and the horsepower and store them as stdX and stdY. . (1pt) You may wish to try the MATLAB functions std(r) and std(y). . (1pt) Write your own function my-std(r) that takes input as a data vector z and returns its standard deviation mX. This function should provide the following result stdx = N = (r; - my-mean(x))2. i= 1 You need to use your own function my-mean(x) to get the mean of r. Compare the result you get from my-std(x) and my-std(y) with std(x) and std(y). 3. (2pt) Determine the median of the displacements and store it as medianX . (1pt) You may wish to try the MATLAB function median(2). . (1pt) Write your own function my-median(2) that takes input as a data vector r and returns its median medianX. You must sort the data vector a in an ascending order into To first, and then proceed to find the median (the mid point). You must write a script that is usable for both odd and even number of samples. Print your result and compare it with the result obtained from the MATLAB function median(I). Notes: You can use the sort() function in MATLAB to sort your data.4. (1pt) Illustrate the data in the table using a scatter plot with the horizontal axis representing the displacements and the vertical axis representing the horsepowers. From the plot, determine whether the displacements and the horsepowers have positive correlation, negative correlation or no correlation. Suggestion: You may wish to try the MATLAB function scatter (r, y). Attach the plot in your report. 5. (1pt) Find the sample covariance of the displacements and the horsepowers and store it as couXY. Suggestion: You may wish to try the MATLAB command N/(N - 1) * mean((x - mr). * (y -my)). Do not use the built-in MATLAB function to calculate the covariance. 6. (2pt) Find the correlation coefficient from the sample covariance and the standard deviations of the displacement and the horsepower. Print the obtained correlation coefficient, and determine if the calculation confirms with your observation from the scatter plot. You must present your report as follows: . Answer each question with the result (including figure) you obtain for your MATLAB code. . Copy and paste all your MATLAB scripts to the end of your report. . Upload a single file report (result + MATLAB code) to Canvas. Deadline: Friday July 1 at 11:59 PM. No late submission is allowed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Trigonometry A Unit Circle Approach

Authors: Michael Sullivan

10th Edition

0321999347, 9780321999344

More Books

Students also viewed these Mathematics questions

Question

Are others in the industry doing the same thing? P-6523

Answered: 1 week ago

Question

2. Have enough shelves so that materials need not be stacked.

Answered: 1 week ago