Select ONLY the functional answers for how one might evaluate if x is greater than 6
x>6
2
New cards
Suppose you have a matrix A, defined by the following:
A = \[3 4\]
Write the output of the following command:
A >= 4
0 1
3
New cards
When declaring a function parameters are defined after the function and between the
Parentheses
4
New cards
Suppose you have a scalar . Write the conditional to test if is greater than or equal to 6.
c>=6
5
New cards
Data abstraction has some important features that we discussed. Select *all* of the following features and statements that are true of data abstraction.
\-the process of considering a variable independently of its associations
* Matlab abstracts the type or variable for us meaning an assighnemnt of an integer is the same as an assignment of a string * done with one assighnment * removes uits related to a variable
6
New cards
Suppose you have a matrix X, which is a three by three matrix (a square). Enter the command to calculate the element-wise third power of X.
X.^3
7
New cards
Suppose you have a three by one matrix , and another three by one matrix . To find the element-wise product (multilpication) of these two, one would use the following
A.\*B
8
New cards
uppose you have a three by one matrix , and a scalar . To find the element-wise sum (addition) of these two, one would use the following
A+B
9
New cards
Suppose you have a three by one matrix , and a scalar . To find the element-wise product (multilpication) of these two, one would use the following
A\*B
10
New cards
Suppose you have a scalar created by the following command:
d = rand(1,1)
Write the command to evaluate if d is lesser than 0.5.
d
11
New cards
Suppose you have a three by one matrix , and another three by one matrix . To find the element-wise different (subtraction) of these two, one would use the following
A-B
12
New cards
When writing a function, we need to start with the following on the first line (assuming one input and one output):
function \[returnOne\] = functionName(inputOne
13
New cards
Select all traits of both a for and while loop that we discussed in class.
* All **for** and **while** loops have an "exit strategy," or a means of determining it's time to stop looping. * All **for** and **while** loops have a starting line that includes the condition test. * All **for** and **while** loops have an ending line. * All **for** and **while** loops have additional "stuff," or code, in the middle.
14
New cards
True or False: Functions allow us to take complex problems, and break them into smaller, and more manageable parts.
true
15
New cards
A **for** loop steps through a *predefined* number of iterations.
true
16
New cards
True or False: The workspace of a function is available to the user or the calling script/function at all times, during and after the function runs.
false
17
New cards
True or False: All functions must include the function declaration, defining that a function is to follow. This looks like:
\ function \[values\] = functionName(parameters)
true
18
New cards
True or False: The help function in Matlab will return the first block of comments in the file, which is typically put right after the function declaration.
true
19
New cards
Assume the following function exists folliowing this structure:
\ function \[A, B, C\] = thisFunctionExample(someInput)
\ And suppose that you want to "save" value B. To do so, you would call the function as follows:
\ B = thisFunctionExample (theInput)
false
20
New cards
A **for** loop inherently runs some *undetermined* number of times, until an exit condition is met.
false
21
New cards
Which of the folloing is how we would structure a **for** loop in Matlab?
for i = startingNumber : endingNumber
% do something
end
22
New cards
rue or False: Formally, functions operate in their own workspace.
true
23
New cards
A **while** loop steps through a *predefined* number of iterations.
false
24
New cards
Assume the following function exists folliowing this structure:
\ function \[A, B, C\] = thisFunctionExample(someInput)
\ And suppose that you want to "save" all of the return values. To do so, you would call the function as follows:
\ \[A, B, C\] = thisFunctionExample(theInput)
true
25
New cards
e talked about two types of iterations, while and for.
true
26
New cards
True or False: Functions ***can return output***, passing information back to the user or other script/function that called it.
true
27
New cards
Let's talk about how we write a function.
True or False: We can write functions inside the Matlab editor window (or a seperate text editor).
true
28
New cards
True or False: Formally, functions take input via values, and provide output via parameters.
false
29
New cards
Assume the following function exists folliowing this structure:
\ function \[A, B, C\] = thisFunctionExample(someInput)
\ And suppose that you want to "save" value A. To do so, you would call the function as follows:
\ A = thisFunctionExample (theInput)
true
30
New cards
A **while** loop steps through each iteration until some condition is met and causes it to exit.
true
31
New cards
True or False: Formally, functions create, and then destroy all variables used while running the function.
true
32
New cards
True or False: Functions ***can take input***, which are passed to the functions as parameters.
true
33
New cards
Which of the folloing is how we would structure a **while** loop in Matlab?
\n while (someCondition)
% do something
end
34
New cards
As a good practice, the second line in your function should include:
\ % the help info,
% documentation on how to use the function,
% what it does,
% author information
% and anything else relevant that the user of your function needs to know.
true
35
New cards
A **while** loop inherently runs some *undetermined* number of times, until an exit condition is met.
true
36
New cards
\n A **for** loop steps through a fixed set of values, iterating once for each value, and then exits.
true
37
New cards
T/F: the horizontal axis on a 2d scatter plot is generally (pretty much always) the independent variable.
true
38
New cards
Files allow us to save data (information) into long term storage. But to save any data, we need to do some key things. What key things did we discuss in class?
* Agree on a format * Read the data out in that same format * Write the data in that format * What was the question again?
39
New cards
T/F: the vertical axis on a 2d scatter plot is generally (pretty much always) the dependent variable.
true
40
New cards
If bytes are made up of bits, why bits? Why a single 1 and 0?
A bit is the smallest unit of information we can make.
41
New cards
\n By using computer programs, a person can do the several things to a file. What of the answers below are things one can do to a file?
* save * close * open * change * read
42
New cards
T/F: Bytes are sets of 8 bits together.
true
43
New cards
Suppose we have a set of data with four different measures in it. One of these measures though, can be thought of as a categorical measure, while the others are continuous measures. How did we plot something like this in class?
* we used both a hold on and an iteration * we plotted each variable on a sperate axis, three of them * each category received a different marker type and color * we used plot3()
44
New cards
Of the regular file type, there are two basic format types. These are? Select the two.
text and binary
45
New cards
We talked about several (6) different file types, but noted that we're going to use one of them in this class. All of our discussion has been around this one type. Which type is this?
regular
46
New cards
Select all featues that are true for a Matlab **struct** data type.
* elements indexed by feild name * indexed by # * hold any basic data type in any location * \
47
New cards
elect all featues that are true for a Matlab **cell array** data type.
* hold any basic type of data in any location * indexed by number * \
48
New cards
T/F: A Matlab **table** is similar to a spreadsheet table (Excel, Number, Gnumeric, etc), in that one can have named columns, and each row is another line of data.
true
49
New cards
integer
stores whole numbers
50
New cards
float
stores decimal value
51
New cards
matrix
For storing row and column type data, that is all a numeric (integer, float) value of some sort
52
New cards
character
a single letter or special character
53
New cards
string
a set of letters such as words
54
New cards
table
For storing row and column type data, where the data in each column is all the same type, but columns can be different types from each other. Each column is named.
55
New cards
cell array
For storing row and column type data, where the data in each column doesn't have to be the same type, and columns can be different types from each other. Each element is indexed by number.
56
New cards
struct
\n For storing data that is indexed by a fieldname, and can be mixed basic data types. This advanced data type is best for sets of data that have different sizes.
57
New cards
Figures, such as scatter plots or line graphs, are nearly useless without additional context. We went through this context in detail. What additional things do we need to add to our figures to make them useful?
y-azis labe
x-axis label
legend
title
58
New cards
T/F: If files are sequences of "chunks" of data in a linear array, those "chunks" are bytes for text files.
true
59
New cards
What is the first part of a binary file called, the part that tells the operating system what kind of file this file is?
header
60
New cards
Why do we plot data, as opposed to just putting everything in a table? Select all that apply.
* to see bigger picture and understand more quickly * To better understand trends and patterns, connecting the independent and dependent variable when appropriate. * Because I can't read binary like Neo, or even tables that are hundreds to millions of cells large, but I can get a good understanding of what's there from an image.
61
New cards
Matlab supports changing detailed properties of plots using the following functions, select all that are true.
dot,
get and set,
adding in the extra property (like MarkerSize) to the plot command when first calling it.
62
New cards
dot
(oop, fieldname) indexing
63
New cards
Select all featues that are true for a Matlab **table** data type.
* can hold any basic data but need to be the same type in the same column * indexed by column name * indexed by number * \
64
New cards
\n T/F: A Matlab **cell array** is like a spreadsheet (Excel, Numbers, Gnumeric, etc), in that each cell contains a number (integer, float) or text (character, string), but it cannot store aything else (other data types).
false
65
New cards
When we work with a file on our computer, we're actually only working with a peice of software that is working with the low level aspects of the file.
true
66
New cards
What is a csv?
a comma seperated vale text file
67
New cards
T/F: A Matlab **struct** is the same as a spreadsheet table (Excel, Number, Gnumeric, etc), in that each cell arranged by row and column and is a container for one and only piece of data.
false
68
New cards
After plotting your data, you could stand back and squint to see what trend you see between the independent and dependent axes, or, you could find a trendline! What's steps are typically needed to add a trendline on to your plot?
69
New cards
Element
A single value or item I. The matrix
70
New cards
Square matrix
A matrix that has the same number of Rowan’s as it has columns
71
New cards
Row vector
A matrix that has a single row
72
New cards
Column vector
A matrix that has a single columb
73
New cards
Array
A matrix with one dimension. Either a row or column vector