Week 8, Chapter 6, ENCMP Flashcards

1
Q

What do functions do?

A

they accept input arguments and return output arguments after performing some type fo calculation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How should primary functions’ names be saves?

A

they should have the same name as the function name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Input and output arguments are merely _______ for values to be passed/returned

A

Input and output arguments are merely placeholders for values to be passed/returned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where are two places that functions can be made

A

Inside the file and outside in a script.m file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

when making a separate file for a function command, what must be at the beginning of the file

A

the function file must begin with the keyword function and should be named with the same filename as the function name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can functions take and return vector inputs and outputs ?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the benifit of functions being able to take and return vector inputs and outputs.

A

Then you can give a function a vector of values and it will compute them inside of the function and then return the values as another set of vectors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an ‘overloadable’ property

A

It is a property that is sometimes used to define a vector calculated inside of an function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you make a function that will accept multiple input and output arguments

A

The function header should look something like this: %function [vol,SA] = cone_vol_SA(R,H)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a call-by-value or pass-by-value

A

•When a function is called, MATLAB makes a copy of the actual input arguments and then passes them to the function

This means that if the function modifies these arguments, it will not affect the data available to the caller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are some advantages of using functions.

A
  • Independent testing of sub-tasks
  • Reusable code
  • Isolation from unintended side-effects
  • Easier maintenance of programs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are some potential disadvantages of using functions

A

Input arguments passed by value to the function must be copied to a new memory location for use in the function’s workspace
When passing large arrays this can be time-consuming and occupy memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a base workspace

A

it is the command winder workspace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a local variable

A

When a function is defined inside of their own file they have their own workspace. It is important to note that the main file cannot access these local files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a breakpoint?

A

Setting breakpoints pauses the execution of your MATLAB® program so that you can examine values where you think an issue might have occurred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the three types of breakpoints?

A
  1. standard 2. conditional 3. error
17
Q

Where can you place breakpoints?

A

You can set breakpoints only at executable lines in saved files that are in the current folder or in folders on the search path.

18
Q

When can you set breakpoints?

A

You can set breakpoints at any time, whether MATLAB is idle or busy running a file.

19
Q

What does matlab do when it reaches a breakpoint?

A

By default, when MATLAB reaches a breakpoint, it opens the file containing the breakpoint.

20
Q

What is wrong with this file name: Week 7 Ch6_ENCMP100_2021_Blanks

A

It has spaces in the name. you cant have that if its going to run properly

21
Q

How do you set a breakpoint ?

A

Open the file, click on the dash of the line at which you want to set the break point, the dash becomes the red dot. click again to cancel.