Consider the following MATLAB code that multiplies two matrices. What is the output?
A = [1 2; 3 4]; B = [5 6; 7 8]; C = A * B; disp(C);
Remember matrix multiplication rules: multiply rows of first by columns of second.
Matrix multiplication of A and B results in [[19 22]; [43 50]] because each element is the sum of products of corresponding row and column elements.
Which of the following reasons best explains why MATLAB is widely used in engineering simulations?
Think about what features help engineers analyze and visualize data easily.
MATLAB offers many built-in functions and specialized toolboxes that simplify numerical analysis and visualization, making it ideal for engineering simulations.
The following MATLAB code attempts to solve a system of linear equations but produces an error. What is the cause?
A = [1 2; 3 4]; b = [5; 6]; x = A / b;
Check the operator used for solving linear systems in MATLAB.
In MATLAB, the backslash operator '\' is used to solve linear systems. Using '/' attempts matrix right division, which is incorrect here.
What will be displayed by this MATLAB code?
x = 0:0.5:2; y = zeros(size(x)); for i = 1:length(x) y(i) = x(i)^2; end plot(x, y); title('Plot of y = x^2'); disp(y);
Calculate squares of each element in x.
The vector y contains squares of x values: 0^2=0, 0.5^2=0.25, 1^2=1, 1.5^2=2.25, 2^2=4.
Choose the feature that best explains why MATLAB is favored for rapid prototyping in scientific research.
Think about how quickly you can run and change code in MATLAB.
MATLAB is an interpreted language, so scientists can write and test code quickly without waiting for compilation, speeding up prototyping.