Skip to content

Commit

Permalink
Add 8 Matlab questions (#2270)
Browse files Browse the repository at this point in the history
Improved formatting in q54 and add 8 question in Matlab-quiz.md

Co-authored-by: Zhenja <evg.bazhanov@yahoo.com>
  • Loading branch information
ehudbehar and Ebazhanov authored Sep 27, 2021
1 parent 1991490 commit bf2b9d0
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions matlab/matlab-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -819,20 +819,22 @@ a = a^2;

#### Q54. Which choice is the correct syntax for declaring a function that returns the input value as the output?

- [ ]

```
function mystery_func(a) :
return a
```

- [ ]
- [x]

```
function b = mystery_func(a)
b = a;
end
```

- [x]
- [ ]

```
def b = mystery_func(a)
Expand All @@ -849,8 +851,6 @@ function mystery_func(a)
end
```

- [ ]

[Reference](https://mathworks.com/help/matlab/ref/function.html)

#### Q55. What is the state of a at the end of this code?
Expand Down Expand Up @@ -902,3 +902,69 @@ a =
- [x] `h_a = gca; set(h_a,'Color', [0 0 0]);`
- [ ] `h_a = axes; set(h_a,'Color', [0 0 0]);`
- [ ] `h_f = gcf; set(h_a,'Color', [0 0 0]);`

#### Q57. Which statement will return all the odd numbers from 1 to 9?

- [ ] `2*[1:5]+1`
- [x] `1:2:9`
- [ ] `isodd(1:9)`
- [ ] `1:odd:9`

#### Q58. In MATLAB, the `imfilter` command performs a convolution operation between an image and a matrix. Suppose you have an image loaded in MATLAB into the variable `img` and you apply the following code. The original image appears slightly blurred because the convolution smoothed out the image (removed noise). Why do you think this happened?

```
h = ones(5,5)/25;
imshow(imfilter(img,h));
```
- [ ] `h` is a Gaussian filter that adds to 1. Its intended effect is to highlight image edges.
- [x] `h` is an averaging filter uniformly distributed that adds to 1. Its intended effect is to smooth out images (remove noise).
- [ ] `h` is a Laplacian filter that adds up to 0. Its intended effect is to smooth out images (remove noise).
- [ ] `imfilter` is a function that always blurs the images.

#### Q59. What is the size of `b`?

```
a = [1 2 3];
b = repmat(a,2,3);
```

- [ ] 1x3
- [ ] 3x2
- [ ] 2x3
- [x] 2x9

#### Q60. Which statement reverses vector `a`?

```
a = [ 1 2 3 4];
```

- [ ] reverse(a)
- [x] a(end:- 1:1)
- [ ] rev(a)
- [ ] a(::-1)

#### Q61. Which command will create a column vector with the values 7, 8, and 9?

- [ ] `c = [7,8,9]`
- [ ] `c = [7: 8: 9]`
- [x] `c = [7; 8; 9]`
- [ ] `c = [7 8 9]`

#### Q62. What do you call in the **command** window to see all the variables in the workspace and their classes?
- [ ] `who`
- [ ] `vars`
- [x] `whos`
- [ ] `who all`

#### Q63. You wrote a new function named `snap` in an m-file and when you call it, you're not getting the output you expect. You previously wrote a different function named `snap`, which you think might also be on the search path. Which command can you use to see if the old `snap` function is being called?
- [x] which
- [ ] who
- [ ] lookfor
- [ ] what

#### Q64. What is a reason to save a MAT-file using the `-v7.3` flag?
- [ ] to ensure backward compatibility
- [ ] to avoid HDF5 overhead in MAT-file
- [x] to include a variable greater that 2GB
- [ ] to use compression by default

0 comments on commit bf2b9d0

Please sign in to comment.