Programming for Engineers

¡Supera tus tareas y exámenes ahora con Quizwiz!

(T/F) A double equal sign (==) is the assignment operator in MATLAB?

F

What is the output after executing the following commands: >> cmat = char ('Hello', 'Hi', 'Ciao'); >> cmat(2,:)

'Hi '

You are given the following MATLAB code: A = 1:5:20. What will be the contents of the variable A after executing this code?

A = [1 6 11 16]

In MATLAB, which of the following functions is commonly used for displaying output to the Command Window or for writing data to files? • A) fprint() B) output() C) disp() D) write()

C

In MATLAB, input function allows for interactive input from the user. The following command is used to read and store numeric data, T/F? >> variablename = input('prompt string' , ' s ')s

F

True/False: In MATLAB, the function name could be different from the name of the m-file in which your function is stored.

False

Given following MATLAB codes, what is the output? n = 8; while n < 10 disp('Hello world') n = n + 1; End

Hello world Hello world

Given following MATLAB codes, what is the output? for i = 1:1:3 fprintf('i is equal to%d\n', i) end

Variable i is equal to 1 Variable i is equal to 2 Variable i is equal to 3

How would you concatenate a vector B = [4 5 6] as the last row to a 3 x 3 matrix A? a) A = [A; B] b) A = [A, B] c) A = A + B d) A = A - B

a

In MATLAB, what is NOT the primary purpose of the input function? A) To display text on the command window. B) To read and store numeric or text data entered by the user during program execution. C) To generate random numbers. D) To create interactive plots and visualizations

b

Which commands are used to display the variable? a) which b) whos c) who d) clear

b

Which is the correct command for deleting the second column of A? A =[2 6 0; 1 8 3] a) A(:,2) = 0 b) A(:,2) = [] c) A(2,:) = [] d) A(2,:) = 0

b

Which of the following statements regarding MATLAB workspace is true? a) Contains folders and files b) Contains variables c) Items from command line are deleted d) Items from workspace cleared using clc command

b

Which code declares a variable that holds the number 1.23 and outputs it formatted with two decimal points? x = 1.23 a) Using disp(x) b) Using printf("x = %.2f/n", x) c) Using fprintf("x = %.2/n", x) d) Omitting semicolon

c

Which is not a valid variable name in MATLAB? A) myVariable B) x1 C) $var D) A

c

Which of the following code fragments transposes a matrix A correctly? a) B = t(A) b) B = transpose[A] c) B = A' d) B = A.transpose(1,0)

c


Conjuntos de estudio relacionados

Principles of Entrepreneurship Quiz 2

View Set

use - Davis Advantage / Edge - Musculoskeletal Trauma and Complications

View Set

Vocabulary in Real-Time Analytics

View Set

Trans,Genderqueer, and Queer Terms Glossary (UTSA GENDER, SEX, AND CULTURE

View Set

Cultural Competence in Health-Care

View Set

6th grade Social Studies Standards

View Set