Ploting & Inner Functions Flashcards

1
Q

How can we graph an XY relationship?

A

By using the command:

plot(x, y)

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

How can we get the maximum or minimum value of an array?

A

max(array) or min(array?

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

How can I get help for finding functions?

A

Click Fx on the command line and use the search bar for finding whatever function you want.

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

How do we get information about what a function does?

A

Use the command “help”. For instance:

help min —> will tell you everything you need you need to know about the function min.

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

Another way to obtain documentation from the original source?

A

Use the following:

doc function —> This will open the official documentation from matlab

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

How do we get the index where the max or min is located?

A

[maxVal, I] = max(y)

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

How do we define functions in the same way as we do in math? As in, with the argument and all?

A

We use “anonymous functions” like this:

y = @(x) (function def)

y = @(x) (x+2).^2

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

How to create a plotting environment?

A

Use figure(#number)

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

How can I plot several graphs on a same figure?

A

By plotting and then holding on, like this:

plot(x,y)
hold on
plot(x,z)

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

How to provide labels to the axis?

A

xlabel(“name of the label”)
ylabel(“name of the label”)

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

How can we add titles to graphs?

A

Using title(“name”) command

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

Activate grids?

A

Grid on

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

How can we add legends?

A

With the legend(“name”) command

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

How can I limit the axes?

A

xlim([a b])
ylimit([a b])

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

How can I fill up discrete points so the can look continuous?

A

Put markers before the color, like for instance:

plot(x, y, “- - g*”)

It will add dashes to fill up

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

How can I plot different images in a single figure but in individual plots?

A

Use the subplot command:

figure(1)
subplot(m, n, #position)

17
Q

How does matlab returns true or false statements?

A

With 1 for true and 0 for false.

18
Q

How can we perform logical comparisons between elements from an array/matrix with a single element?

A

Matlab makes it easier by simply comparing the array/matrix with that element:

A > 2

Here, if A is an array/matrix, it will check if every element is greater than 2 and it will return an array of the same size of A with 0s and 1s.

19
Q

How can I add or multiply all the elements of an array?

A

Using sum(A) or prod(A)