MATLAB MATLAB Numerical Methods and Optimization 1 — Questions and Answers
Question 1: Which MATLAB function solves a system of linear equations Ax = b?
- linsolve(A, b) or A\b (Correct answer)
- solve(A, b)
- linalg(A, b)
- eig(A, b)
Correct answer: linsolve(A, b) or A\b
MATLAB solves linear systems using the backslash operator A\b or the linsolve function.
Question 2: What does the MATLAB function `fzero` do?
- Finds a root of a nonlinear scalar function (Correct answer)
- Sets all array elements to zero
- Computes the zero-crossing frequency
- Evaluates a function at zero
Correct answer: Finds a root of a nonlinear scalar function
fzero finds a zero (root) of a scalar nonlinear function near a specified starting point.
Question 3: Which function in MATLAB computes numerical integration using adaptive quadrature?
- integral (Correct answer)
- trapz
- cumsum
- diff
Correct answer: integral
The integral function uses adaptive Gauss-Kronrod quadrature to numerically integrate a function over a specified interval.
Question 4: What does the `ode45` function use to solve differential equations?
- Runge-Kutta 4th/5th order method (Correct answer)
- Euler's explicit method
- Adams-Bashforth method
- Finite difference method
Correct answer: Runge-Kutta 4th/5th order method
ode45 implements a variable-step Runge-Kutta method of orders 4 and 5 for solving ODEs.
Question 5: Which MATLAB function finds the minimum of an unconstrained multivariable function?
- fminsearch (Correct answer)
- min
- optimize
- fsolve
Correct answer: fminsearch
fminsearch uses the Nelder-Mead simplex algorithm to minimize a multivariable function without constraints.
Question 6: What does the `polyfit(x, y, n)` function return in MATLAB?
- Coefficients of a polynomial of degree n fitted to data (Correct answer)
- A plot of the polynomial
- The integral of the polynomial
- The roots of the fitted polynomial
Correct answer: Coefficients of a polynomial of degree n fitted to data
polyfit returns a row vector of n+1 coefficients representing the least-squares polynomial fit of degree n to the data.
Which MATLAB function solves a system of linear equations Ax = b?