Final Quiz

Forty questions covering the whole course.

Concept

Forty questions covering the whole course. Answer before reading the answers; revisit the referenced module for every miss.

Why It Matters

Testing yourself shows exactly which topics need another look.

Example

Stage 1 — Fundamentals Q1. What does x = 5; display?

Answer: Nothing — the semicolon suppresses output.

Q2. What is the class of 3?

Answer: double.

Q3. What is int8(120) + 10?

Answer: 127 (saturation).

Q4. What does [1 2 3] .* [4 5 6] return?

Answer: [4 10 18].

Q5. Why does [1 2 3] * [4 5 6] fail?

Answer: Matrix multiplication needs inner dimensions to match (1×3 times 1×3).

Q6. What is mod(-7, 3)?

Answer: 2.

Q7. What does A(end, :) select?

Answer: The last row.

Q8. Which element is A(5) in a 3×3 matrix?

Answer: Row 2, column 2 (column-major).

Q9. How do you solve A x = b?

Answer: x = A \ b.

Q10. What does sum(A, 2) compute?

Answer: The sum of each row.

Q11. How do you compare two texts?

Answer: strcmp(a, b) (or strcmpi ignoring case).

Q12. What is str2double('abc')?

Answer: NaN.

Q13. When is if [1 0 1] true?

Answer: Never — all elements must be nonzero.

Q14. What does for c = M iterate over?

Answer: The columns of M.

Stage 2 — Programming Q15. Script vs function?

Answer: Functions have their own workspace and explicit inputs/outputs.

Q16. What does [~, idx] = max(v) do?

Answer: Returns only the index of the maximum.

Q17. What do nargin and nargout report?

Answer: The number of inputs passed and outputs requested.

Q18. What does an anonymous function capture?

Answer: The values of variables at the moment it is created.

Q19. c{1} vs c(1) for a cell array?

Answer: Contents vs a 1×1 cell.

Q20. How do you collect a numeric field from a struct array s?

Answer: [s.field].

Q21. How do you check that a map contains a key?

Answer: isKey(m, key).

Q22. What does fgetl return at the end of a file?

Answer: -1.

Q23. What does hold on do?

Answer: Keeps existing plots in the axes when adding new ones.

Q24. What does meshgrid produce?

Answer: Coordinate matrices for evaluating functions of two variables.

Q25. How do you catch only a specific error?

Answer: Check err.identifier in the catch block and rethrow others.

Q26. What is onCleanup for?

Answer: Running cleanup code (closing files, instruments) when a function exits, even on errors.

Stage 3 — Numerical Computing Q27. Which order do polynomial coefficients use?

Answer: Descending powers.

Q28. What does interp1 return outside the data range by default?

Q29. What does R² measure?

Answer: The fraction of the data's variance explained by the fit.

Q30. What does a large condition number mean?

Answer: The solution is very sensitive to errors in the data.

Q31. How do you solve a second-order ODE with ode45?

Answer: Rewrite it as a system of first-order ODEs.

Q32. Which solver do you use for stiff problems?

Answer: ode15s (or ode23s).

Q33. What convergence does Newton's method have near a simple root?

Answer: Quadratic — the number of correct digits roughly doubles each iteration.

Q34. What is the Nyquist frequency for fs = 2 kHz?

Answer: 1 kHz.

Q35. How do you scale an FFT to get amplitudes?

Answer: Divide by N and double the single-sided bins (except DC and Nyquist).

Q36. What does the integral term of a PID controller do?

Answer: Removes steady-state error.

Q37. What does accumarray(g, v, [], @mean) compute?

Answer: The mean of v for each group index in g.

Q38. Value vs handle class?

Answer: Value objects are copied on assignment; handle objects are shared references.

Q39. Name three ways to speed up MATLAB code.

Answer: Vectorize, preallocate, use built-ins (\, sum, …); also profile first, parfor, MEX/Coder.

Q40. How do you combine two CAN bytes lo and hi of a little-endian 16-bit signal?

Answer: raw = lo + bitshift(hi, 8).

Common Mistakes

Reading the answer before committing to your own.

Skipping the "why" behind each answer.

Best Practices

Retake the quiz a week later.

For every miss, rerun the verified example in the referenced module.

Interview Relevance

The questions mirror typical interview and exam questions.

Practice Questions

Write five more questions about your weakest stage.

Turn Q8 and Q40 into small scripts that verify the answers.

Explain Q31 with the damped-oscillator example.

Explain Q35 with the spectrum example.

Quick Quiz

Q1. (True/False) A score of 80 % means you are ready to apply MATLAB in projects.

Answer: True — combined with finishing the practice exercises.

Q2. (Multiple choice) Which module covers FFT scaling? A) 7 B) 13 C) 25 D) 30 Answer: C.

Q3. (Predict the output) mod(-7, 3) Answer: 2.

Q4. (Find the bug) "I missed Q13, so I'll memorize 'never'."

Answer: Rerun Module 9's example to understand the rule (all elements nonzero and non-empty).

Coding Challenge

Verify quiz answers Q3, Q6, Q8 and Q40 with one script.

fprintf('Q3: int8(120) + 10 = %d\n', int8(120) + 10)
fprintf('Q6: mod(-7, 3) = %d\n', mod(-7, 3))
A = reshape(1:9, 3, 3);
[r, c] = ind2sub(size(A), 5);
fprintf('Q8: A(5) is row %d, column %d\n', r, c)
lo = hex2dec('40'); hi = hex2dec('1F');
fprintf('Q40: raw = %d\n', lo + bitshift(hi, 8))