What command turns a row vector into a column vector?
x' or transpose(x)
What MATLAB function can be used to initialize a vector with undefined values?
NaN or zeros or ones (for init)
What is the MATLAB command to generate a 10 Hz sine wave over 1 second?
t = 0:0.01:1; x = sin(2*pi*10*t);
What command creates a structure with fields: name, score, and pass?
struct('name','A','score',90,'pass',true)
What MATLAB function would you use to read a numeric .txt file with a single column?
readmatrix or load
What happens if you perform x + y when x is a 1×5 vector and y is a 5×1 vector?
Dimension mismatch error (1×5 + 5×1 not valid for element-wise ops)
Why is growing a vector inside a loop discouraged?
MATLAB reallocates memory every iteration, slowing execution
How does plot() differ from stem() in signal visualization?
plot draws lines, stem shows discrete points
How do you access the third student’s GPA in a structure array named students?
students(3).GPA
What does writematrix(data, 'output.txt') do?
Saves numeric array to output.txt
Explain why length() may not be sufficient for checking matrix size in 2D arrays.
length() only returns the largest dimension, not all dims like size()
Write a script snippet to preallocate a 1000-element column vector of ones
A = ones(1000, 1);
Why does undersampling cause a misrepresentation of the signal frequency?
Undersampling causes high frequencies to appear lower (aliasing)
Write a loop to display all student names who have graduated == true.
for i=1:length(students), if students(i).graduated, disp(...), end
Name two reasons C++ outputs must be cleaned before being imported into MATLAB.
Quotes and commas cause parsing errors in readtable/str2num
True or False: zeros(3,1) preallocates a row vector. Justify your answer.
False – zeros(3,1) creates a column vector, not row
Compare runtime performance of a loop with vs. without preallocation using tic and toc.
Use tic, run loop with/without preallocation, then toc
Given t = 0:0.01:1;, what is the effective sampling frequency?
1 / 0.01 = 100 Hz
What data structure would you use to store mixed signal packets of strings and numbers?
Cell array — supports mixed data types
Write a one-line MATLAB command to read a file called average_results.txt and plot the value.
bar(readmatrix('average_results.txt'))
Given v = [5 10 15 20], write a line of code to double only the values greater than 10.
v(v > 10) = v(v > 10) * 2;
Identify the logical error:
No error, but should preallocate: A = zeros(1,1000); first
Modify a sine wave signal to simulate Gaussian noise using built-in MATLAB functions.
signal_noisy = signal + 0.2 * randn(size(signal));
Define a nested structure for a robotic joint that includes position and a motor substructure.
Describe a real-world engineering reason to connect C++ pre-processing with MATLAB visualization.
C++ is faster at preprocessing; MATLAB is better for visualization