Plotting & Visualization
Filtering & Analysis
Logical Indexing & Conditions
Debugging MATLAB Code
Structures, Cell Arrays & Functions
200

What command adds a label to the y-axis of a plot?

ylabel('Label')

200

What function smooths a signal using a moving average?


movmean or smoothdata

200

 How would you find values in a vector x greater than 5?


x(x > 5)

200

Identify the syntax error: plot x, y)


plot(x, y) – fix missing parentheses

200

Define a structure named sensor with fields id, value, and unit.


sensor = struct('id','TEMP01','value',3.2,'unit','Volts')

400

How do you overlay multiple plots on the same figure?


Use hold on; before plotting the second line

400

Describe what movmean(signal, 5) does.


Computes rolling mean using a 5-sample window

400

What does x(x<0.5) = NaN; do?


Replaces all values < 0.5 with NaN

400

Why would MATLAB throw an error for mean('abc')?


'abc' is a char array, not numeric; mean expects numeric

400

How can you store a variable-length list of readings across multiple sensors?


Store each reading in a cell array: {} for variable length

500

What does grid on do and why is it helpful in signal plots?


Adds grid lines to improve readability

500

Write a script(1-liner) that filters all values below 0.3 in a signal using NaN.


signal(signal < 0.3) = NaN;

500

Write a script that counts how many values in a vector x are between 0.3 and 0.7.


sum(x > 0.3 & x < 0.7)

500

What happens if you use disp() on a struct array without specifying a field?


Displays all struct content; need to specify a field like .name

500

What function allows you to apply an operation to each cell in a cell array?


cellfun(@function, cellArray)

800

Which plot type would best visualize a matrix of signal amplitudes over time?

imagesc, surf, or heatmap

800

What is the danger of taking a mean of a vector with NaN values?


mean() returns NaN if any element is NaN

800

 Explain how logical indexing is used in structure arrays. using "students"

students([students.graduated] == true)

800

How would you fix this warning: "Matrix dimensions must agree"?


Use element-wise operators like .* or reshape inputs

800

Write a simple anonymous function to compute the square of a number.


f = @(x) x.^2;

1000

Fix this line of code: title 10Hz Sine Wave


title('10Hz Sine Wave') — fix missing parentheses and quotes

1000

Replace all NaN values in a vector x with the number 0.


x(isnan(x)) = 0;

1000

What function identifies which elements in a vector are NaN?


isnan(x)

1000

What function or technique helps you measure execution time of script sections?


tic and toc

1000

Convert a structure array into a cell array using MATLAB functions.


struct2cell() or cellArray = struct2cell(structArray)

M
e
n
u