What command adds a label to the y-axis of a plot?
ylabel('Label')
What function smooths a signal using a moving average?
movmean or smoothdata
How would you find values in a vector x greater than 5?
x(x > 5)
Identify the syntax error: plot x, y)
plot(x, y) – fix missing parentheses
Define a structure named sensor with fields id, value, and unit.
sensor = struct('id','TEMP01','value',3.2,'unit','Volts')
How do you overlay multiple plots on the same figure?
Use hold on; before plotting the second line
Describe what movmean(signal, 5) does.
Computes rolling mean using a 5-sample window
What does x(x<0.5) = NaN; do?
Replaces all values < 0.5 with NaN
Why would MATLAB throw an error for mean('abc')?
'abc' is a char array, not numeric; mean expects numeric
How can you store a variable-length list of readings across multiple sensors?
Store each reading in a cell array: {} for variable length
What does grid on do and why is it helpful in signal plots?
Adds grid lines to improve readability
Write a script(1-liner) that filters all values below 0.3 in a signal using NaN.
signal(signal < 0.3) = NaN;
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)
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
What function allows you to apply an operation to each cell in a cell array?
cellfun(@function, cellArray)
Which plot type would best visualize a matrix of signal amplitudes over time?
imagesc, surf, or heatmap
What is the danger of taking a mean of a vector with NaN values?
mean() returns NaN if any element is NaN
Explain how logical indexing is used in structure arrays. using "students"
students([students.graduated] == true)
How would you fix this warning: "Matrix dimensions must agree"?
Use element-wise operators like .* or reshape inputs
Write a simple anonymous function to compute the square of a number.
f = @(x) x.^2;
Fix this line of code: title 10Hz Sine Wave
title('10Hz Sine Wave') — fix missing parentheses and quotes
Replace all NaN values in a vector x with the number 0.
x(isnan(x)) = 0;
What function identifies which elements in a vector are NaN?
isnan(x)
What function or technique helps you measure execution time of script sections?
tic and toc
Convert a structure array into a cell array using MATLAB functions.
struct2cell() or cellArray = struct2cell(structArray)