Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi professor gave us 2 question i did question 1 and i post the answer also i only need question 2 thanks please do this

hi professor gave us 2 question i did question 1 and i post the answer also i only need question 2 thanks please do this on matlab software

image text in transcribed

fcreate.m

close all

clear

clc

filename = 'num.txt';

vec = [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.2 3.3 6.7 3.6 3.7 3.7];

fid = fopen(filename, 'w');

fprintf(fid, '%.1f', vec(1));

for i=2:length(vec)

fprintf(fid, ' %.1f', vec(i));

end

stand.m

close all

clear

clc

filename = 'num.txt';

fid = fopen(filename, 'r');

vector = fscanf(fid, '%f')

vector_sum = sum(vector)

vector_mean = mean(vector)

deviation = vector - vector_mean

output of stand.m

image text in transcribed

please do question 2 on mat lab

1) Compute Standard Deviation i. Create an m-file called 'fcreate' as illustrated above. Run it to print out the following numbers in a data file called num.txt. 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.2 3.3 6.7 3.6 3.7 3.7 Follow the following steps to create a program called stand.m which computes the standard deviation of ii. the data in num.txt. a) Load the above data file which is now a vector! b) Compute the sum of all of the numbers: Output this value. Use sum( c) Obtain the average (called the mean value in statistics) and output it. Use meanO d) Compute the difference of each value from the average and store it in an array called deviation using a for loop and an expression deviation(i)-num(C)-average; output it along with its number(i) in a table with labeled columns. e) Simultaneously (within the same loop) compute the sum of all the deviations and call it checksum and output it after the loop. Do not use the sumO function. f) Simultaneously sum all the squares of the deviations in the loop and call it sum_squ. g) Compute the average of the sum_squ (Use total number of values-1). This number is called the variance in statistics and output it. Compute the square root of the variance- known as the standard deviation and output it. it with your calculated standard deviation above. Show percent difference if there is a difference. It h) i Finally use the MATLAB function std0 on the row vector of numbers! Output this value and compare should be very close if not 0! 2) Write a program which creates a data file called numbers.txt that you can load following numbers into it. Then write another program that will take the square root of each number saved in numbers.txt and then save them to a file called rootfiin txt. Re sure to save numhers with 4 numbers.txt, the m file created for this task and output file rootfun.txt. decimal precision. Print up the 1) Compute Standard Deviation i. Create an m-file called 'fcreate' as illustrated above. Run it to print out the following numbers in a data file called num.txt. 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.2 3.3 6.7 3.6 3.7 3.7 Follow the following steps to create a program called stand.m which computes the standard deviation of ii. the data in num.txt. a) Load the above data file which is now a vector! b) Compute the sum of all of the numbers: Output this value. Use sum( c) Obtain the average (called the mean value in statistics) and output it. Use meanO d) Compute the difference of each value from the average and store it in an array called deviation using a for loop and an expression deviation(i)-num(C)-average; output it along with its number(i) in a table with labeled columns. e) Simultaneously (within the same loop) compute the sum of all the deviations and call it checksum and output it after the loop. Do not use the sumO function. f) Simultaneously sum all the squares of the deviations in the loop and call it sum_squ. g) Compute the average of the sum_squ (Use total number of values-1). This number is called the variance in statistics and output it. Compute the square root of the variance- known as the standard deviation and output it. it with your calculated standard deviation above. Show percent difference if there is a difference. It h) i Finally use the MATLAB function std0 on the row vector of numbers! Output this value and compare should be very close if not 0! 2) Write a program which creates a data file called numbers.txt that you can load following numbers into it. Then write another program that will take the square root of each number saved in numbers.txt and then save them to a file called rootfiin txt. Re sure to save numhers with 4 numbers.txt, the m file created for this task and output file rootfun.txt. decimal precision. Print up the

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

What about leadership lessons from particularly good or bad bosses?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago