MATLAB Vectors
Dynamic Memory & Preallocation
Signal Processing Basics
MATLAB Structures & Data
File I/O and Integration
100

What command turns a row vector into a column vector?

x' or transpose(x)

100

What MATLAB function can be used to initialize a vector with undefined values?

NaN or zeros or ones (for init)

100

 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);

100

What command creates a structure with fields: name, score, and pass?


struct('name','A','score',90,'pass',true)

100

 What MATLAB function would you use to read a numeric .txt file with a single column?


readmatrix or load

200

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)

200

Why is growing a vector inside a loop discouraged?


MATLAB reallocates memory every iteration, slowing execution

200

How does plot() differ from stem() in signal visualization?


plot draws lines, stem shows discrete points

200

How do you access the third student’s GPA in a structure array named students?


students(3).GPA

200

What does writematrix(data, 'output.txt') do?


Saves numeric array to output.txt

300

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()


300

 Write a script snippet to preallocate a 1000-element column vector of ones

A = ones(1000, 1);

300

Why does undersampling cause a misrepresentation of the signal frequency?


Undersampling causes high frequencies to appear lower (aliasing)

300

Write a loop to display all student names who have graduated == true.


for i=1:length(students), if students(i).graduated, disp(...), end

300

 Name two reasons C++ outputs must be cleaned before being imported into MATLAB.


Quotes and commas cause parsing errors in readtable/str2num

400

 True or False: zeros(3,1) preallocates a row vector. Justify your answer.

False – zeros(3,1) creates a column vector, not row

400

Compare runtime performance of a loop with vs. without preallocation using tic and toc.

Use tic, run loop with/without preallocation, then toc

400

Given t = 0:0.01:1;, what is the effective sampling frequency?


1 / 0.01 = 100 Hz

400

What data structure would you use to store mixed signal packets of strings and numbers?


Cell array — supports mixed data types

400

Write a one-line MATLAB command to read a file called average_results.txt and plot the value.


bar(readmatrix('average_results.txt'))

500

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;

500

Identify the logical error:


No error, but should preallocate: A = zeros(1,1000); first

500

Modify a sine wave signal to simulate Gaussian noise using built-in MATLAB functions.

signal_noisy = signal + 0.2 * randn(size(signal));

500

Define a nested structure for a robotic joint that includes position and a motor substructure.


500

Describe a real-world engineering reason to connect C++ pre-processing with MATLAB visualization.

C++ is faster at preprocessing; MATLAB is better for visualization

M
e
n
u