Engineering > Quiz > Essential MATLAB for Engineers and Scientists, Seventh Edition (Quizzes with Solutions, All Chapters (All)

Essential MATLAB for Engineers and Scientists, Seventh Edition (Quizzes with Solutions, All Chapters)

Document Content and Description Below

‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions for Chapter 1, Lecture 1. The correct answer is highlight... ed. 1. Create two variables by assigning 4 and 5 to x and y. Assign the value of x + y to the variable z. What two statements do this correctly? a. 4 = x; 5 = y; x+y = z b. x = 4; y = 5; z = x+y c. x = 4; 5 = y; z = x+y 2. To convert angles in radians to angles in degrees, which factor do you need to multiply radians to covert to degrees correctly? a. 2*pi/360 b. 360/(2*pi) c. 180/(2*pi) 3. Consider the row of numbers generated by the command >> x = 1:1:11; % How many numbers are in the list? a. 10 b. 12 c. 11 4. Consider the row of numbers generated by the command >> x = 1:2:11; % How many numbers are in the list? a. 5 b. 6 c. 7 5. Plot the sine of x from 0 to pi. To do this, which command do you enter? a. x = 0:2*pi/100:2*pi; plot(x,sin(x)) b. x = 0:2*pi/100:pi; plot(x,sin(x)) c. x = pi:2*pi/100:2*pi; plot(x,sin(x))‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions for Chapter 2, Lecture 2. The correct answer is highlighted. 1. Which of the following names are valid, variable names? a. pay-plan b. 22d c. watt 2. Does MATLAB recognize the difference between a and A? a. Yes b. No 3. If you clear and assign the variables as shown and then execute who, what variables are in the work space? >> clear; a = 5; Bab = 3; a. a ans Bab b. a Bab c. A Bab 4. Create an array by executing the following command: >> A = [ [1;2;3] , [4;5;6] , [7;8;9]] >> A(2) % is equal to what number in the array? a. 4 b. 2 c. 5 5. Consider the array created by the following command: >> A = [ [1;2;3] , [4;5;6] , [7;8;9]] >> A = A' >> A(2) % is equal to what number in the array? a. 4 b. 2 c. 6‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 3: The correct answer is in bold. 1. The Command Window is the MATLAB window where we enter commands. True or False 2. Which of the following windows displays previous commands you have entered? Command Window History Window Old Commands Window Command History Window Entered Commands Window 3. The file type that we save MATLAB programs in is called a: Function file M-file Code file Doc-file X-file 4. The result of two-hundred-eighty-three times pi divided by seven is (using MATLAB): 40.0000 0.0777 630.5719 127.0101 3.14156 5. The clc command exits MATLAB. True or False 6. MATLAB automatically puts comments in our code when we create a code and save it in an M-File. True or False 7. Which of the following characters is used by MATLAB to perform multiplication? ~ * Æ This is the correct answer. + % &‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 4: The correct answer is in bold. 1. A scalar is a 2-by-2 array. True or False 2. Vectors are 1-by-n or n-by-1 arrays. True or False 3. A matrix is an m-by-n array, where m and n are integers. True or False 4. To multiply 2 arrays element-by-element, what operator must you use? + * .* Æ This is correct answer ./ - 5. When you create (or assign) arrays, a comma separates the columns in each row and a semicolon denotes the start if the next row. True or False 6. Which of the following are valid variable names: PLANCKSCONSTANT _age 3rdJuniper first_circle score‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 5: The correct answer is in bold. 1. If a = 1 2 3 4 5 6 then which of the following is the result of a' ?Which of the following is the result of a' ? 6 5 4 3 2 1 6 5 4 3 2 1 1 4 Correct answer. 2 5 3 6 4 1 5 2 6 3 2. If a = 1 2 3 4 5 6 then what command extracts the second column of matrix a? a(:,2) a(3,2) a(2,:) a(;,2) a(end,:) a(2,;)‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. 3. If a = 1 2 3 4 5 6 then what is the result of the command a(2,1)? Answer is 4. 4. When multiplying matrices element-by-element, a dot-operator must be used. True or False 5. Is there a dot-operator for the addition of arrays element-by-element? Yes or No 6. When dividing matrices element-by-element, a dot-operator must be used. True or False‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 6: The correct answer is in bold. 1. For x = Acos(wt), when A = 4 cm, w = 0.6 rad/sec and t = 3sec, what is x -0.9088 cm -0.2272 cm 0.2272 cm 3.8954 cm 2.6413 cm 2. What is the square root of 338 (to 4 decimal places)? Answer is 18.3848 3. What does the command [a, b] = max(x) do? Finds the maximum value in vectors a and b. Finds the maximum value and its position in vector x. Finds the position of the maximum value in vectors a and b. Finds the maximum value and minimum value. Forms an a by b matrix of maximum values. 4. Compute the sum of the terms in the vector F, where F = [56, 46, 36, 44, 76, 60, 39, 33, 39, 44, 36, 42, 15, 24,100, 144, 45, 34, 33, 23, 47, 59, 47, 33, 54,209, 39, 56, 43, 22, 37, 55] Answer in 1670. 5. Find the product of the elements in vector R, then divide it by 500, where R = [0.06, 0.4, 36, 4.4, 0.6, 6.0, 3.9, 0.033, 3.9, 4.4, 3.6, 42, 1.5, 0.024, 1, 0.4, 4.5, 4, 0.33, 0.23, 0.47, 5.9, 7, 33, 2.9, 0.9, 0.56, 0.03, 0.22] Answer is 1.1111 6. Find the standard deviation of F, where F = [56, 46, 36, 44, 76, 60, 39, 33, 39, 44, 36, 42, 15, 24, 100, 144, 45, 34, 33, 23, 47, 59, 47, 33, 54, 209, 39, 56, 43, 22, 37, 55] Answer is 37.3038 7. What is the tangent of 16 degrees? Answer is 0.2867‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 7: The correct answer is in bold. 1. Which one of the following commands is used to read data from a Microsoft Excel file named ‘spreadsheet’? xlsread('spreadsheet') readexcel('spreadsheet') readxls('spreadsheet') excelread('spreadsheet') 2. Is there an error in the following list of commands? x = 1; y = 3; z = 5; w = log(z - x*y) Yes or No 3. The following command has what kind of error? Syntax Run-time Logical There is no error in this line of code. 4. The following commands contain a logical error. % Calculate square root of x square_root = x.^2; True or False 5. The following command extracts data from the text file ‘data.txt’. uiimport(‘data.txt.’) True or False 6. Which of the following command lines loads the data from ‘test.mat’ into the MATLAB workspace? open test.mat read test.mat load test.mat loadfile test.mat‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 8: The correct answer is in bold. 1. Which of the following blocks of code does not plot y=10x^2 and y = x^3 on the same figure? plot(x, 10.^2, x, x.^3); hold on; plot(x, 10*x.^2); plot(x, x.^3); hold off; figure (1) plot( x, 10*x.^2); figure(2) plot(x, x.^3); figure(1) plot(x, 10*x.^2, x, x.^3); 2. Which of the following lines of code plots y versus x with a red line? plot('r', x, y); plot(x, 'r', y); plot(x, y, 'r'); plot(y, x, 'r'); 3. Which of the following commands plots y = x^5 with a dashed line, triangle right markers, and in green? plot(x, x.^5, '-->g'); plot(x, x.^5, 'drtg'); plot(x, x.^5, 'dash r-tri green'); plot(x, x.^5, '-g>'); 4. The hold on command allows the user to plot more than one set of data on a single figure. True or False.‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. 5. The following command does what? plot(x, sin(x), 'yp') Plots sin(x) vs. x with a yellow plus sign marker and no line Plots sin(x) vs. x with yellow pentagram markers and no line Plots x vs. sin(x) with yellow plus sign markers and no line Plots x vs. sin(x) with yellow pentagram markers and no line 6. Which of the following sets of commands does not plot e^x and ln(x) on the same figure? plot(x, exp(x)); hold on; plot(x, log(x)); hold off; plot(x, exp(x), x, log(x)); figure(1) plot(x, exp(x)); figure(2) plot(x, log(x)); figure(1) plot(x, exp(x), x, log(x)); 7. We can plot several curves on a single figure. True or False‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 9: The correct answer is in bold. 1. Which one of the following commands plots a graph in the lower right corners of a 3 x 3 grid of graphs? subplot(3,3,1) subplot(3,3,3) subplot(3,3,7) subplot(3,3,9) 2. The command pie(z) creates a pie chart of z. True of False 3. The built-in command logxlogy creates a plot with logarithmic scaling on both the x and the y axes. True or False 4. Which of the following commands plots r = sin(theta) in polar coordinates? polar(theta,r); polar(r,theta) plot(theta,r) plot(r,theta) 5. The polyfit function with degree 3 selected, produces a cubic model for the data x =[1,4,6,9,11,14,15] , y = [-2,175,613,2110,3878,8045,9910]. It is given by the formula y = 3x^3 - x^2 + x - 5. True or False 6. To evaluate the function y = 3x^3 - x^2 + x – 5 over a range of x = 1:100, with coef = [3, -1, -5], which command can you use? polyval(coef, x) model(coef, x) polyfit(coef, x) linereg(coef, x) 7. If coef=[3, 0, -1, 2, 7] , does polyfit(coef, x) return 3x.^5 - x.^3 + 2x.^2 + 7x? Yes or No‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 10: The correct answer is in bold. 1. Given the function y = x * ln(x), compute the definite integral of this function from x = 17 to x = 23. Hint: Try using sym2poly to get an exact number. Answer is 359.94. 2. Given the function y = x * ln(x), find its derivative with respect to x. What is it? log(x) + 1 x * log(x) log(x) x / log(x) 3. Given the function y = x * ln(x), what is the value of y at x = 3.25? 2.67 3.27 3.83 4.32 4. Given the function y = x * ln(x), what is the root of y? 0 1 2 3‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 11: The correct answer is in bold. 1. Any variable in the workspace can be accessed by a user-defined function. True or False 2. Which of the following is NOT a valid name for a function? Poker Blackjack Solitare 52 Card Pickup 3. The first line of a function that takes as input mass and velocity and outputs kinetic energy would resemble which of the following: function energy = kinetic_energy(mass,velocity) function[mass,velocity] = kinetic_energy(energy) kinetic_energy = function(mass,velocity) [mass,velocity] = function(kinetic_energy) 4. A function must return numerical output.True or False 5. Write a function that converts lengths from inches to centimeters. Programming question‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 12: The correct answer is in bold. 1. In the command fprintf within the string statement what operator executes a linefeed? \n \l \nl \new \new_line 2. To display formatted output in the command window, we used the plot command. True or False 3. Which one of the following is a valid placeholder in an fprintf statement %d %n %p %r %v 4. The input command can only take text as input. True or False 5. Which of the following commands will ask the user to input a radius and store it in a variable called radius? input=radius('Enter a radius: ') radius=('Enter a radius') radius=input('Enter a radius') input(radius)=('Enter a radius: ') input=('Enter a radius: ') 6. Write a program to ask for a number and determine if the number is positive, negative, or neither. 7. Write a program to ask for input of a radiation level and determine if that radiation level is safe. (A level less than 4 curies is safe.)‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 13: The correct answer is in bold. 1. Consider the following assignment of variables: a=3; b=4; c=true; d=1; If the following commands are executed after the assignment of variables what are their truth values? In other words are they True(1) or False(0)? a. a|b % True or False b. (a+b)< (b+a) % True or False c. ~c&b % True or False d. (b-a)==d % True or False e. abs(b-a) == abs(a-b) % True or False f. isnumeric(c) % True or False g. isnumeric(d) % True or False h. isempty(a) % True or False i. c == d % True or False j. (a|b)&c % True or False‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 14: The correct answer is in bold. 1. Loops are MATLAB constructs that allow a set of commands to be executed multiple times. True or False 2. A for loop repeats: Forever Until the user stops the loop A set number of times known before the loop is executed An unknown number of times A set number of times unknown before the loop is executed 3. The vector may be used to increment a for loop by using the following construct: first : increment : last increment : first : last last : increment : first increment : last : first first : last : increment 4. How many times will a for loop starting with for = 1:3:19 execute (or repeat)? 0 3 6 7 19 5. A for loop construct must end with an end statement. True or False 6. After the execution of the following loop, what will be the values of the elements of vector b? a=[3 7 1 9 11]; for i=1:1:5 b(i)=a(i)^2 + i; end b=[10 51 4 85 126] b=[9 49 1 81 121] b=[3 7 1 9 11] b=[1 2 3 4 5] b=[4 9 4 13 16]‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 15: The correct answer is in bold. 1) While loops repeat a block of commands as long as a logical expression is false. True or False 2) While loops can be used to ensure that the user inputs the proper type of data. True or False 3) Once the logical expression at the start of a while loop is false, the statements after the end statement are executed. True or False 4) How many times will the following loop repeat? i = 2; while i <= 16; i = i+2; end 0 times 2 times 8 times 16 times infinite 5) The following loop will repeat until while text(x); x = x+1; end forever until test(x) is false until test(x) is true 0 times It is impossible to tell. 6) The following loop will repeat how many times? n = 1; while n < 5 n = n - 1; end Pick an answer: 0, 1, 4, 5, or infinite.‘Essential MATLAB for Engineers and Scientists’ 7e © 2019 Daniel Valentine. All rights reserved. Published by Elsevier. Quiz questions 16: . 1. Write a program uses a loop to calculate the decibel level (dB) of power levels between 1 Watt and 20 Watts in 0.5 Watt increments. Plot dB versus power using one of the semilog plot commands. The equation needed is as follows: dB = 10*log10(P2/P1) where P2 is the measured power and P1 is a reference power of 1 Watt (in this problem). 2. Write a function that uses a for loop and accepts two sets of input data, viz.: A vector of test scores. The number of scores. The function should return the number of passing grades. Your function must use both of the input values. Assume that the lowest passing grade is a 60%. [Show More]

Last updated: 8 months ago

Preview 4 out of 18 pages

Buy Now

Instant download

We Accept:

We Accept
loader

Loading document previews ...

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$10.00

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

48
0

Document information


Connected school, study & course


About the document


Uploaded On

Sep 28, 2024

Number of pages

18

Written in

Seller


seller-icon
Expert#1

Member since 5 years

412 Documents Sold

Reviews Received
39
8
3
2
8
Additional information

This document has been written for:

Uploaded

Sep 28, 2024

Downloads

 0

Views

 48


$10.00
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·