Question
MATLAB You are to construct a program to compute the STANDARD DEVIATION of a group of numbers. The standard deviation gives one a sense of
MATLAB
You are to construct a program to compute the STANDARD DEVIATION of a group of numbers. The standard deviation gives one a sense of the spread of data around the mean (what we called the average above).
i) Create the m-file like fcreate.m as illustrated above. Run it to print out the following numbers in a data file called num.txt. Print it up with the type command!
3.2 3.1 3.5 3.2 3.0 3.1 3.9 3.6 3.9 3.6 3.9 3.4 3.23.3 6.73.63.7 3.7
ii) Now create the program called stand.m to compute the standard deviation of the data it obtains from the data file, num.txt.
Outputs of the numbers and their deviations calculated as below should be in labeled columns.
iii) Program should load the above data file which is now a vector!
iv) Compute the sum of all of the numbers: Output this value. Use sum()! Not a Scalar calculation!
v) Obtain the average (called the mean value in statistics) and output it. Use mean()
vi) Compute the difference of each value from the average called the deviation using a for loop and an expression like dev(i)=num(i)-ave; output it along with its number(i) in labeled table. Here we treat each number individually as a scalar and thus create a new vector dev in the end.
vii) Simultaneously (within the same loop) compute the sum of all the deviations call it the checksum and output it after the loop. Ie; checksum =?
viii) Simultaneously sum all the squares of the deviations in the loop.
ix) Compute the average of the last sum (the average of the deviations squared). Use one less than the total number. This number is called the variance in statistics and output it.
x) Compute the square root of the variance- known as the standard deviation and output it.
xi) Have your program use the MATLAB function std() on the row vector of numbers! Output these values and compare them with your calculations above. What are the differences if any? show percent difference if there is a difference. It should be very close if not 0!
The program you construct will carry out all actions discussed in the above 12 parts. Print program (type filename) and output and the data file to hand in.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started