Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Considering that the first line of the MATLAB code in MATLAB script is as follows. function coeffs - StraightLineFit (x,y) What should be the

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1. Considering that the first line of the MATLAB code in MATLAB script is as follows. function coeffs - StraightLineFit (x,y) What should be the name of the file, if you wanted to save this code to a MATLAB file in order to [2 marks) use it? 2. Define each of the following special variables. ans Inf NaN [3 marks) 3. All the following MATLAB commands except one can be used to create the row vector x = [1 2 3 4 5). Identify the incorrect command. >> x=(1 2 3 4 5); >> x=(1 2 3 4 5] >> x=(1;2;3;45] >> x=(1,2,3,4,5) [3 marks) 4. 1 2 3 Write a MATLAB syntax to create matrix A = 4 17 8 9 5 6 [3 marks) 5. Look at the following sample of MATLAB code (which has line numbers added for ease of reference) and answer the following questions. 3 1 2 3 4 5 6 7- 8- function freefalli 13 freefalli: interactive bungee velocity & freetalli interactive computation of the free-fall velocity of an object with second-order drag, - 9.81: acceleration of gravity m = input (Mass (kg) : '); cd = input('Drag coefficient (kg/m) : '); t = input('Time (s): "); disp('') disp(' ') disp(' ') disp('') disp('Velocity (m/s) :') disp(sqrt(g m/ cd) tanh (sqrt (cd / m) - t)) 10 - 11 - 12 13 - 14 - 15 - a) What should you write in the command window to invoke the function? [1 mark] b) What is the first line that will be displayed after invoking the function? [1 mark] c) Explain the function of input syntax in this sample code. [1 mark) d) What is the function of line number 11? [1 mark] e) What is the function of line number 14? [1 mark] f) What is the function of line number 15? [1 mark] 6. Look at the following sample of MATLAB code (which has line numbers added for ease of reference) and answer the following questions about it. total - 0; for k - 1:15 total = 7***2 - 2** + total; end disp('The sum for 15 terms is:') disp (total) 5 6 a) Specify the main MATLAB feature that is used in this sample [3 marks] b) How many times calculation in the closed loop will be executed if you run this code? [3 marks] 7. Name two MATLAB conditional statements. [3 marks) 8. Name two MATLAB loops and write the basic general structure for one of them. [3 marks) 9. Write the following equations in matrix form. xi(k+1) = C11X1(k) + a(k) xz(k+1) = C21x1(k) + C22x2(k) + d(k) x3(k+ 1) = C32x2(k) + C33x3(k) x (k+1) = C12X3(k) + Cesxs(k) where Cy are coefficients, and a(k), and d(k) are constants [4 marks) 10. Look at the following sample of MATLAB code (which has line numbers added for ease of reference) and answer the following questions about it. Table 1 is on the next page. 2 3 Table 1. shows the data for the measured heights of 100 men 20 years of age The heights were recorded to the nearest 1/2 in. This code estimate the mean and standard deviation for the height data. Further it estimates how many 20-year-old men are no taller than 68 in. Finally, it cumputes how many are within 3 in. of the mean. 5 7 Absolute frequency data. Y_abs = 11,0,0,0,2,4,5,4,8, 11, 12, 10, 9, 8, 7,5,4,4,3,1,1,0,1)) binwidth = 0.5; 10 Define the bins. bins - [64:binwidth:75): 12 Fill the vector y_raw with the raw data. 13 Start with an empty vector. Y_raw- 15 - Efor 1-1. length (y_abs) 16 - if y_abs (i)>0 17 - new-bins (i) ones (1,Y_abs(i)); 18- else 19- new- 20- end 21 - Y_raw-ly_raw, new]; Stok GROW> 22 - end 23 Compute the mean and standard deviation. 24- mu = mean (y_raw) sigma = std{y_raw) 25 - mumkCASGEL> 26- s = signa: 27 How many are no taller than 68 inches? bl = 687 P1 = (1+ert((b1-mu)/(a+sqrt(2))))/2 30 - a2 = 66.3; b2 = 72.31 P2 = (erf ( (b2-ma)/(a+sqrt (2)))-er{(a2-mu)/(a+sqrt (2)}}}/2 b) c) How many loops and conditional statements are there? Specify the number of lines where the loops and conditional statements start and finish. [3 marks) What is the general purpose for the codes from line 13 to the line 21? [3 marks] Explain the reason for choosing the values of the variables of line 30 and line 31. Suppose that the calculated mean is 69.3, and if the formula for calculating the probability of variable x that is is no less than a and no greater than b is written as Pasx sb), and that it can be computed as follows: Pa Sxsb) = = }LF (**)-ers ( (4 marks) / continued Height (in.) Frequency Frequency 64.5 0 0 65.5 Height (in.) 70 70.5 71 71.5 72 72.5 73 715 66.5 67 675 68 68.5 60 11 745 75 10 Table 1

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 Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

Students also viewed these Databases questions

Question

l Identify the three different roles of HR management.

Answered: 1 week ago

Question

Answered: 1 week ago

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago